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.

Advertisements

One Response to “Attachment Fu”

  1. 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!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: