Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add Gravatars to your Rubies/Rails!

tag: 1.5.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.textile

Easily add Gravatars to your Ruby objects.

Install

sudo gem install chrislloyd-gravtastic —source=http://gems.github.com

Usage

Somewhere in your application you need to require 'gravtastic'. In Rails >= 2.1 you can forego this and just add a dependency gem dependency for Gravtastic.

config.gem ‘gravtastic’, :source => ‘http://gems.github.com/’

The next step is to give your model a Gravatar:

class User has_gravatar end

If you are using a standard Ruby class or Datamapper resource you have to add the line include Gravtastic::Model before has_gravatar.

This defaults to looking for the gravatar ID on the email method. So, if your User has an email then it will send that to Gravatar to get their picture. You can change the default gravatar source like this:

has_gravatar :on => :author_email

Now, you can access your object’s gravatar with the gravatar_url method:

current_user.gravatar_url => “http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG”

Note that it defaults to a PG rating. You can specify extra options with a hash:

current_user.gravatar_url(:rating => ‘R18’, :size => 512) => “http://gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG&s=512” current_user.gravatar_url(:secure => true) => “https://secure.gravatar.com/e9e719b44653a9300e1567f09f6b2e9e.png?r=PG”

PS. Bonus points for anybody who can tell me what that users email is!
PPS. Shame on Automattic for still using MD5!

The Future

Authors

Contribute

You can checkout the source or fork it yourself from Github.

git clone git://github.com/chrislloyd/gravtastic.git

If you submit a successful patch then you’ll be given full commit rights to the project.

Thanks

License

Copyright © 2008 Chris Lloyd.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.