2016-02-12 46 views
0

在我on Rails應用程序的紅寶石,下面分別爲頭,以獲取一個片斷登錄的用戶頭像:軌道4成爲Facebook的頭像通過https

<% if current_user.get_avatar_url.present? %> 
            <img src="<%= current_user.get_avatar_url %>" width="40" height = "40" class="img-circle profile-nav"/> 
           <% else %> 
            <img src="<%= asset_url('default-avatar.png') %>" width="40" height = "40" class="img-circle profile-nav"/> 
           <% end %> 

而且controller代碼分別爲:

def get_avatar_url 
    ret = '' 
    if self.profile.present? && self.profile.user_avatar.present? 
     ret = self.profile.user_avatar.avatar.thumb.url 
    end 
    if ret.blank? && self.provider == 'facebook' 
     ret = self.profile.avatar 
    end 
    ret = '/assets/default-avatar.png' if ret.blank? 
    ret 
end 

現在,當我檢查的頁面,我得到的是這樣的:

<img src="http://graph.facebook.com/xxxxxxxxxx/picture?type=large" width="40" height="40" class="img-circle profile-nav"> 

現在造成混合內容娃控制檯上

Mixed Content: The page at 'https://www.example.com/#_=_' was loaded over HTTPS, but requested an insecure image 'http://graph.facebook.com/xxxxxxx/picture?type=large'. This content should also be served over HTTPS. 

我該如何解決這個問題?謝謝!!

回答

0

您使用的是OmniAuthconfiguration顯示通過https加載的選項secure_image_url=true