Skip to content

Instantly share code, notes, and snippets.

@rogeliog
Created April 11, 2013 16:43
Show Gist options
  • Save rogeliog/5365021 to your computer and use it in GitHub Desktop.
Save rogeliog/5365021 to your computer and use it in GitHub Desktop.
Gravatar
application_helper.rb
def avatar_url(user)
if user.avatar_url.present?
user.avatar_url
else
default_url = "#{root_url}images/guest.png"
gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
"http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment