Single avatar upload: attachment_fu or file_column?

I’m struggling with a single avatar upload system for a user. I’ve hit
brick walls with two different routes, so I’d appreciate pointers on
choosing the right solution and fixing it:

First attempt: attachment_fu (via this tutorial:
http://railsforum.com/viewtopic.php?id=15389 ). However, I can’t get
attachment_fu to crop the images, even with the suggestion outlined in
this post ;
http://brendanlim.com/2007/7/28/crop-images-using-attachment_fu-and-rmagick

If I include a ! next to the dimensions (as suggested), RMagick seems to
ignore the dimensions and save all the thumbnails as the ‘resize’ size.
Could it be my version of RMagick? Has attachment_fu been updated to
crop images? I have to get cropping working, so this is a show stopper!

Second attempt: file_column. The guys from Less Everything have a
solution in their LovdByLess app which would work really well. They used
the file_column plugin to store an ‘icon’ in the users table, and so
users can only have one icon, which is exactly what I need in my app
(and they have cropping working, too!). However, I’ve tried route, and
file_upload is hitting a “No such file or directory” error during the
upload process. It’s saving and cropping images to /user/avatar/tmp on
the file system - so at least I know the cropping is working this time -
but my UsersController is hitting this; “Errno::ENOENT in
UsersController#update”, “No such file or directory” during the upload
process.

Attachment_fu seems to be the preferred choice, but the file_column
route would, presumably, require less work to enforce the one avatar
only restriction. Any suggestions?

There is also a new one out there called paperclip. It seems pretty
nice and easy to use. Not sure about cropping, but it just calls
ImageMagick itself, so it probably wouldn’t be too hard to add that.

http://thoughtbot.com/projects/paperclip
http://groups.google.com/group/paperclip-plugin/topics
http://paperclip.lighthouseapp.com/projects/8794-paperclip/overview

dusty wrote:

There is also a new one out there called paperclip. It seems pretty
nice and easy to use. Not sure about cropping, but it just calls
ImageMagick itself, so it probably wouldn’t be too hard to add that.

http://thoughtbot.com/projects/paperclip
http://groups.google.com/group/paperclip-plugin/topics
http://paperclip.lighthouseapp.com/projects/8794-paperclip/overview

Wow, that looks great. I’m sure I heard about it in a Rails Envy podcast
a little while back - wish I’d remembered.

I managed to fix my problem with attachment_fu (and have, for the time
being at least, settled on using it for my avatars). It appears that I
had to explicitly call the rmagick processor in my has_attachment
options (no else seemed to be doing so!). In combination with a very
handy tutorial (link below) I managed to get cropped thumbnails working
exactly as I wanted;
http://stuff-things.net/2008/02/21/quick-and-dirty-cropping-images-with-attachment_fu/

Now I just need to work out the best measures for only allowing single
avatars per user. Now I’ve come across paperclip, I’m betting it would
be the best option for simply overwriting user avatars each time a user
uploads a new one (rather than dealing with deletion and choosing
defaults each time). So now I still have an avatars model, avatars
table, etc - and Paperclip would make it a whole lot simpler!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs