Attachment Fu
Attachment_fu is an awesome Rails plugin which would make your life easier by taking care of all of your file upload needs. It even creates thumbnails for images and handles validation for you. Sweet. I won’t be getting into tutorial mode here because Mike Clark did a very good job with that and you should drop by his site if you want to learn more about how to use the plugin. Instead here are some stuff I encountered while developing with attachment_fu.
If you are developing in Windows, you might encounter a weird bug where attachment_fu will complain that “Size not included in list” and when you check the file it has a size of 0. Apparently you have to put a sleep before saving the image. So instead of doing:
@mugshot = Mugshot.new(params[:mugshot])
@mugshot.save
You should do:
@mugshot = Mugshot.new(params[:mugshot])
sleep 5
@mugshot.save
Sleep 1 should be fine but I used 5 just to be sure. I think this applies to Windows only because I haven’t encountered it anywhere before.
This entry was posted on June 12, 2008 at 9:27 pm and is filed under Programming with tags attachment_fu, ruby on rails. You can follow any responses to this entry through the RSS 2.0 feed You can leave a response, or trackback from your own site.
October 8, 2008 at 4:14 pm
Thank you so much for the tip about sleeping! I am working on Windows and was having a problem with size complaints from attachment fu. Now it works fine. Thanks again!!