# Single avatar upload: attachment\_fu or file\_column?

**URL:** <https://www.ruby-forum.com/t/single-avatar-upload-attachment-fu-or-file-column/133946>\
**Category:** Rails\
**Created:** [April 5, 2008, 11:11am UTC](https://www.ruby-forum.com/t/single-avatar-upload-attachment-fu-or-file-column/133946 "2008-04-05T11:11:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [April 5, 2008, 11:11am UTC](https://www.ruby-forum.com/t/single-avatar-upload-attachment-fu-or-file-column/133946/1 "2008-04-05T11:11:52Z")

</div>

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](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](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?

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [April 5, 2008, 6:25pm UTC](https://www.ruby-forum.com/t/single-avatar-upload-attachment-fu-or-file-column/133946/2 "2008-04-05T18:25:09Z")

</div>

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.

> **[thoughtbot case studies featuring design and development projects for...](https://thoughtbot.com/case-studies)**
>
> Check out some thoughtbot case studies featuring design and development projects for websites, mobile and web applications across HealthTech, EdTech, FinTech B2B and B2C.

[http://groups.google.com/group/paperclip-plugin/topics](http://groups.google.com/group/paperclip-plugin/topics)  
[http://paperclip.lighthouseapp.com/projects/8794-paperclip/overview](http://paperclip.lighthouseapp.com/projects/8794-paperclip/overview)

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [April 5, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/single-avatar-upload-attachment-fu-or-file-column/133946/3 "2008-04-05T23:21:13Z")

</div>

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.
> 
> [thoughtbot case studies featuring design and development projects for websites, mobile and web applications.](http://thoughtbot.com/projects/paperclip)  
> [http://groups.google.com/group/paperclip-plugin/topics](http://groups.google.com/group/paperclip-plugin/topics)  
> [Lighthouse - Beautifully Simple Issue Tracking](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/](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!
