首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Rails 4通过https为Facebook头像提供服务

Rails 4通过https为Facebook头像提供服务
EN

Stack Overflow用户
提问于 2016-02-12 12:35:02
回答 1查看 92关注 0票数 1

在我的ruby On rails应用程序上,下面是header获取登录用户头像的代码片段:

代码语言:javascript
运行
复制
<% 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代码是:

代码语言:javascript
运行
复制
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

现在,当我检查页面时,我得到的结果如下:

代码语言:javascript
运行
复制
<img src="http://graph.facebook.com/xxxxxxxxxx/picture?type=large" width="40" height="40" class="img-circle profile-nav">

现在会在控制台上引起混合内容警告

代码语言:javascript
运行
复制
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.

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

EN

回答 1

Stack Overflow用户

发布于 2016-02-29 22:44:56

你在使用OmniAuth吗?configuration显示了一个通过https加载的选项secure_image_url=true

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35354889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档