Archive for June 22nd, 2006
Plugin: file_column
This is straight from the “file_column website”:http://www.kanthak.net/opensource/file_column/:
Just make the “image” column ready for handling uploaded files…
class Entry < ActiveRecord::Base
file_column :image
end
… generate file fields *that keep uploaded images during form redisplays to your view…
<%= file_column_field “entry”, “image” %>
… and display uploaded images in your view:
<%= image_tag url_for_file_column(“entry”, “image”) %>
However, you may want to protect against the model object having no uploaded image:
<%= image_tag url_for_file_column(“entry”, “image”) if @entry.image %>
To resize every uploaded image to a maximum size of 640×480, you just have to declare an additional option.
class Entry < ActiveRecord::Base
file_column :image, :magick => { :geometry => “640×480>” }
end
You can even automatically create versions in different sizes that have nice filenames…
class Entry < ActiveRecord::Base
file_column :image, :magick => {
:versions => { “thumb” => “50×50″, “medium” => “640×480>” }
}
end
… and display them in your view:
<%= image_tag url_for_file_column(“image”, “entry”) %>
8 comments June 22, 2006






