Don't Reinvent The Wheel
Next time you install attachment_fu and begin to create an avatar model, stop and consider Gravatar.com. Gravatar allows people to store avatars linked to their email addresses. You probably have heard of Gravatar before but did you know there is a really easy ruby lib for integrating it into your Rails applications?
If you did, pat yourself on the back and move on to the next article in your feed reader but if you didn’t, check out the code below. It assumes that you have installed the gravatar gem (
sudo gem install gravatar).
require 'rubygems' require 'gravatar' puts Gravatar.new('firstname.lastname@example.org').to_s # => http://gravatar.com/avatar.php?gravatar_id=e13c31390e0369fcd5972292ce0e7b92&size=80
Yep, that’s it. If the gravatar_id exists, you get the url to a person’s avatar and if it doesn’t, you get a simple default avatar from gravatar.com.
Personally, I’m tired of uploading my avatar each time I create an account. Let’s build on what others have created instead of constantly reinventing the wheel. Mix this with some openid and you have really simple account registration, authentication and personal avatars.