Line 1 – Installation
Gravtastic is a Gravatar gem created by Chris Lloyd.
1 sudo gem install gravtastic
Line 2 – Configuration
1 sudo gem install gravtasticI like the choice of creating a gem instead of a plugin, makes it usable by more than just Rails.
1 config.gem ‘gravtastic’
Line 3 – Integration
1 config.gem ‘gravtastic’
Notice I’m using DataMapper, works just fine, no need to tweak anything. I do have a field called email that gravtastic picks up on, but you could specify another field name if you wanted.
1 class Comment
2 include DataMapper::Resource
3
4 is_gravtastic
5
6 #rest of code
7 end
Line 4 – Implementation
1 class Comment
2 include DataMapper::Resource
3
4 is_gravtastic
5
6 #rest of code
7 end
Finally just need to display the link to the image next to whoever is commenting.
1 <%= image_tag(comment.gravatar_url(:size=>25)) %>
4 lines for auto avatar icons? Now that’s slightly coded!

I have also created a simple gravatar plugin http://hasham2.blogspot.com/2007/07/using-gravatar-plugin-to-embed-avatars.html
Hi, looks like you are using DataMapper....but the title says using Ruby on Rails....do you have an example where not using DataMapper for ORM?
well, I'm still using rails, just using the more supreme (in my humble opinion) DataMapper for this blog. But I think the use is exactly the same, all you have to do is just say 'is_gravtastic' in your model with an 'email' column in your table. If you got any other questions, lemme know.
is there a way to just gravatar_url('email@domain.com')? I haven't created the user models yet but want to set up the views and pass dummy emails
Useful one. Will try it out !