Skip to content

Instantly share code, notes, and snippets.

@AdamBrodzinski
Created August 23, 2012 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBrodzinski/3433461 to your computer and use it in GitHub Desktop.
Save AdamBrodzinski/3433461 to your computer and use it in GitHub Desktop.
Gravatar Rails Helper
# returns the Gravatar for the given user.
def gravatar_for(user)
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}"
image_tag(gravatar_url, alt: user.name, class:"gravatar")
end
# This is a small rails helper that returns a users gravatar image
# image alt text defaults to user.name, but can easily be changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment