Skip to content

Instantly share code, notes, and snippets.

@TXDynamics
Created April 24, 2013 14:13
Show Gist options
  • Select an option

  • Save TXDynamics/5452427 to your computer and use it in GitHub Desktop.

Select an option

Save TXDynamics/5452427 to your computer and use it in GitHub Desktop.
Pass a value directly to a class method
# An example of passing a value to a method within a class directly
def gravatar_for(user, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "http://www.gravatar.com/avatar/#{gravatar_id}.jpg?s=#{size}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment