I'm working through the Michael Hartl's Ruby on Rails Tutorial, and I've added code to display a user's Gravatar image. It works fine in Firefox and Safari, but not in Chrome (the image just doesn't show up).

The view:

#app/views/users/show.html.erb

<% provide(:title, @user.name) %>
<h1>
  <%= gravatar_for @user %>
  <%= @user.name %>
</h1>

and helper:

#app/helpers/users_helper.rb

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

What's wrong here?

有帮助吗?

解决方案

For me, I had to add (http://localhost:3000/) to Ghostery's whitelisted sites to solve the same issue.

其他提示

I'd recently installed Ghostery in Chrome, and it was blocking the image.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top