2014-01-30 36 views
3

我正在使用Michael Hartl的Ruby on Rails Tutorial,並添加了代碼以顯示用戶的Gravatar圖像。它在Firefox和Safari中正常工作,但在Chrome中不起作用(圖像只是不顯示)。Rails:Chrome中沒有顯示Gravatar圖像

的觀點:

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

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

和助手:

#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 

有什麼不對嗎?

+1

我已經在FF和Chrome中測試了這個代碼,工作正常。 HTML輸出看起來如何? –

+0

也適用於我。也許重新啓動chrome和你的服務器,然後重試。如果這不起作用,請嘗試清除緩存。 – ChrisBarthol

回答

5

對我來說,我不得不向Ghostery的白名單網站添加(http://localhost:3000/)來解決同樣的問題。

2

我最近在Chrome中安裝了Ghostery,它阻止了圖像。