Skip to content

Instantly share code, notes, and snippets.

@Arcath
Created July 19, 2010 12:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Arcath/481321 to your computer and use it in GitHub Desktop.
Save Arcath/481321 to your computer and use it in GitHub Desktop.
gravatar avatar url generating helper method, simply pass an email to it
def gravatar_url(email,options = {})
require 'digest/md5'
hash = Digest::MD5.hexdigest(email)
url = "http://www.gravatar.com/avatar/#{hash}"
options.each do |option|
option == options.first ? url+="?" : url+="&"
key = option[0].to_s
value = option[1].to_s
url+=key + "=" + value
end
url
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment