file_colum

file_column是一款相当不错的,用于上传文件,生成缩略图的一款ROR插件
下面介绍使用方法

安装为组件

./script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk

在model里修改

validates_format_of :image,  
    :with=>/^.*(.jpg|.JPG|.gif|.GIF)$/,  
    :message => "你只能上传JPG或则GIF的图片文件"  
  file_column :image, :magick => {   
         :versions => { "thumb" => "50x50", "medium" => "640x480>" }  
     }  


Just make the "image" column ready for handling uploaded files...

    class Entry < ActiveRecord::Base         file_column :image     end     

在view里修改:

... generate file fields that keep uploaded images during form redisplays to your view...

    <!---->     

... and display uploaded images in your view:

    <!---->     

你可能感兴趣的:(ActiveRecord,Rails)