Adding Gravatar to your App

Created by Catherine Jones

This guide assumes that you have already built a Rails Girls app by following this app development guide and added authentication using Devise.


You need to have an e-mail address registered with Gravatar for this to work. If you do not already have one you can go to

1. Add the Gravtastic gem

Open up your gemfile and under your devise gem add

gem 'gravtastic'

In the terminal run

bundle install

This will install the gravtastic gem. Then remember to restart your rails server.

2. Set up Gravatar in your app

Open app/models/user.rb, and add these lines

include Gravtastic

right after the first line.

3. Configure Gravatar

Open app/views/layouts/application.html.erb and in the

<% if user_signed_in? %>

section but before the

<% else %>


<%= image_tag current_user.gravatar_url %>

Now open you app in your browser and login with an e-mail address that is associated with a Gravatar. You should be able to see your Gravatar.