Project

gravity

0.0
No commit activity in last 3 years
No release in over 3 years
A simple gravatar plugin for Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
 Project Readme

Gravity

Gravity is a simple Gravatar plugin for Rails. It allows you to easily get Gravatar images and profile informations.

Installation

Just add it to your Gemfile like this:

gem "gravity"

and you're ready to go.

Usage

In your model:

class User < ActiveRecord::Base
  has_gravatar
end

In your views:

<%= image_tag @user.gravatar_image %>
<%= @user.gravatar_profile['displayName'] %>

This works if you have an email field in your model. To use a different field for email, pass the field name to the :email option:

class User < ActiveRecord::Base
  has_gravatar :email => :email_address
end

You can also pass options to the ´gravatar_image´ and ´gravatar_profile´ methods:

<%= image_tag @user.gravatar_image :size => 40, :default => 'identicon' %>
<%= @user.gravatar_profile(:secure => true)['displayName'] %>

Here is a complete list of options:

Option Description Default Values
secure Use SSL to call gravatar.org false true/false
size The size of the image 80 1..512
default The avatar image used by default none "404", "mm", "identicon", "monsterid", "wavatar", "retro" or an absolute URL (this must start with "http").
rating The lowest level of ratings you want to allow G G, PG, R or X
forcedefault Force usage of the default image false true/false

See the Gravatar site for more informations.

Copyright (c) 2011 Giuseppe Capizzi, released under the MIT license