Gravatar image is not displayed, although the correct URI is Ruby on Rails

I am working on a Michael Hartl Rails tutorial and am having a weird problem adding a Gravatar section. I checked the code against another implementation of Gravatar in Rails, which I did for another tutorial, and I don’t see what is different.

Basically: the image does not appear, but if you right-click on the space and go to the URL that it will direct to the correct Gravatar page.

Code: (show.html.erb)

<%= gravatar_for @user %> 

Code: (users_helper.rb)

 def gravatar_for(user, options = { size: 50 }) size = options[:size] gravatar_id = Digest::MD5::hexdigest(user.email.downcase) gravatar_url = "https://secure.gravatar.com/avatars/#{gravatar_id}.png?s=#{size}" image_tag(gravatar_url, alt: user.name, class: "gravatar") end 

Completely dead end, I know, probably, something really obvious that I went missing, but from the book and the Gravatar website I seem to be right about this ...

+4
source share
4 answers

Invalid URL

 gravatar_url = "https://secure.gravatar.com/avatars/#{gravatar_id}.png?s=#{size}" 

correct version

 gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}.png?s=#{size}" 

singular form "... / avatar / ...."

+7
source

I had the same issue that I resolved by specifying Cloud9 page in Adblock and ghostery

+4
source

Is this the whole users_helper.rb file?

My looks like this:

 module UsersHelper # Returns the Gravatar (http://gravatar.com/) for the given user. def gravatar_for(user) gravatar_id = Digest::MD5::hexdigest(user.email.downcase) gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}" image_tag(gravatar_url, alt: user.name, class: "gravatar") end end 

Via

module UsersHelper

and additional

end

0
source

The same goes for me. I fixed this by changing gravatar_url to " http://gravatar.com/avatar/# {gravatar_id}" rather than the https connection.

0
source

All Articles