Plugin for uploading files in Rails
Posted by Jeff Kupperman Mon, 06 Nov 2006 05:02:02 GMT
This definitely looks worth a try...
http://weblog.techno-weenie.net/articles/acts_as_attachment
Updates:
1. In the instructions above, I haven't gotten the rake to work, but it doesn't seem to matter.
2. See the thumbnail tutorial at: http://weblog.techno-weenie.net/articles/acts_as_attachment/thumbnailing
3. Change the create_or_update_thumbnail function as follows, in: vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment.rb:
def create_or_update_thumbnail(file_name_suffix, *size)
returning thumbnail_class.find_or_create_by_thumbnail_and_parent_id(file_name_suffix.to_s, id) do |thumb|
thumb.attributes = {
:content_type => content_type,
:filename => thumbnail_name_for(file_name_suffix),
:attachment_data => resize_image_to(size)
}
callback_with_args :before_thumbnail_saved, thumb
thumb.save!
end
end
Here's the code from my demonstration implementation.
Update for IPD folks: If you're getting errors when you try to install, enter this command and then do the script/plugin commands:
export http_proxy="http://141.216.3.2:8080"
The reason has to do with an http proxy on the UM-Flint network....
Spread the word.
Jeff Kupperman supports RSS (Real Simple Syndication), and Trackbacks from other blogs.
Your Comments.
Leave your own response