[Rails] the use of Gravatar in Rails

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
In two versions, one is not set size, one can set the size of.

Do not set the following:

module ApplicationHelper
  def avatar_url(user)
    gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
    " {gravatar_id}.png?s=200"

So in the view:

<%= image_tag avatar_url(user) %>

Set size.:

module UsersHelper

  # Returns the Gravatar ( ) for the given user.
  def gravatar_for(user, options = { size: 50 })
    gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
    size = options[:size]
    gravatar_url = " {gravatar_id}.png?s=#{size}"
    image_tag(gravatar_url, alt: user.name, class: "gravatar")

<%= gravatar_for @user %>

The time of the call can add dimensions.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Sampson at January 14, 2014 - 5:17 PM