File column plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk/
In your model make your image column use the plugin
class User < ActiveRecord::Base file_column :picture
Include the correct form field in your view
<%= file_column_field "user", "picture" %>
Display the image in your views
<%= image_tag url_for_file_column("user", "picture") %>
File column also allows you to use rmagick easily to complete different tasks on a uploaded image.
Resize image:
file_column :picture, :magick => { :versions => { "small" => "100x140", "middle" => "150x220", "portfolio" => "190x400", :square => {:crop => "1:1", :size => "50x50", :name => "square"} } }
Check image type:
validates_file_format_of :picture, :in => ["gif", "png", "jpg"]
Check image size:
validates_filesize_of :picture, :in => 0..2.megabyte
Further Documentation
Edit plugin | Back in time (1 older version) | Last edited by: scott, about 1 year ago

