Setting up gravatar's in your rails app

4 Mar 2009, by Michael Cindrić

Gravatars allow users to configure an avatar to go with a users email address at a central location: http://gravatar.com. Gravatar-aware websites can then look up and display each user's preferred avatar, without having to handle avatar management. This makes life easy on the developer and the user only has to manage one central location.

First step is to get the plugin

ruby script/plugin install git://github.com/woods/gravatar-plugin.git

Now most user models have an email field so it's usually something like below to access their email.

  user.email

If thats the case then to have the gravatar appear in your views it's simply

<%= gravatar_for @user %>

Thanks Scott A. Woods for a great and simple plugin.


Cookies help us deliver our services. By using our services, you agree to our use of cookies.