rhnorment
(Hunt Norment)
December 12, 2017, 12:53am
1
Code from the tutorial:
module AvatarHelper
def avatar(user)
email_digest = Digest::MD5.hexdigest(user.email)
gravatar_url = "https://gravatar.com/gravatar/#{email_digest}"
image_tag(gravatar_url)
end
end
Browser shows this:
Generated HTML is:
<img src="https://gravatar.com/gravatar/dffd0b1c36bd23ce08a438c8157ec16f" alt="Dffd0b1c36bd23ce08a438c8157ec16f">
When I browse to the image link manually, the Gravatar appears. But the app is showing the ‘alt’ instead of the image.
I’m sure it’s something real stupid I’m doing.
Anyway, thanks in advance for any tips.
/Hunt
pbmarcano
(Pete Marcano)
December 14, 2017, 3:04am
2
Can you show me the contents of your app/views/shouts/_shout.html.erb
file?
Mine looks like this:
<div>
<%= avatar(shout.user) %>
<%= link_to shout.username, shout.user %>
<%= render shout.content %>
<%= link_to shout do %>
<%= time_ago_in_words(shout.created_at) %> ago
<% end %>
<%= like_button(shout) %>
</div>
rhnorment
(Hunt Norment)
December 14, 2017, 10:31pm
3
@pbmarcano , here you go. Looks to be the same as yours:
<div>
<%= avatar(shout.user) %>
<%= link_to(shout.username, shout.user) %>
<%= render shout.content %>
<%= link_to(shout) do %>
<%= time_ago_in_words(shout.created_at) %> ago
<% end %>
<%= like_button(shout) %>
</div>
Not sure when this lesson was created, but did the API for fetching a Gravatar image change when Wordpress took over Gravatar?
pbmarcano
(Pete Marcano)
December 15, 2017, 12:01am
4
Woops! Found the difference between our two apps.
Remove the https:
at the beginning of your gravatar_url string in your AvatarHelper
module.
My finished product is up in a heroku instance at http://90stwitter.com , you can compare the generated html there.
Also, Gravatar was acquired by Automattic in 2007, and this course was updated for Rails 5 earlier this year. I think the API is pretty stable at this point.
rhnorment
(Hunt Norment)
December 20, 2017, 9:54pm
5
Thank you , kindly. Simple and careless URL issue on my part.
1 Like