Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gravatar image not displaying although URI correct - Ruby on Rails

I'm working through the Michael Hartl Rails Tutorial and I'm getting a weird problem with the 'adding a Gravatar' section. I've checked the code against another implementation of a Gravatar in Rails I did for a different tutorial and don't see what's different.

Basically: the image doesn't appear, but if you right click the space and visit the URL it directs 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

Totally stumped, know it's probably something really obvious that I'm missing, but from the book and the Gravatar website I seem to have gone about this right...

like image 806
Alex Lynham Avatar asked Dec 20 '22 10:12

Alex Lynham


1 Answers

The url is wrong

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/...."

like image 163
ycs1988 Avatar answered Apr 30 '23 19:04

ycs1988