Rails 4通过https

时间:2016-02-12 04:35:02

标签: ruby-on-rails ruby facebook https

在我的ruby on rails应用程序中,以下是用于获取已登录用户头像的标题的片段:

<% 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.

我该如何解决这个问题?谢谢!

1 个答案:

答案 0 :(得分:1)

您使用的是OmniAuth吗? configuration显示加载https的选项secure_image_url=true

相关问题