【发布时间】:2014-03-26 11:51:09
【问题描述】:
我有这段代码用于从 Facebook 获取头像...
if auth.info.image.present?
user.update_attribute(:avatar, URI.parse(auth.info.image))
end
当我现在尝试加载代码时,出现此错误:
A RuntimeError occurred in authentications#create:
redirection forbidden: http://graph.facebook.com/672086173/picture?type=square -> https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t5.0-1/1086349_672086173_156380036_q.jpg
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/open-uri.rb:223:in `open_loop'
我知道这是 Open-URI 不允许 HTTP 到 HTTPS 重定向的问题...我知道这可以通过 Open-Uri-Redirections 插件https://github.com/jaimeiniesta/open_uri_redirections 解决
但是有两点我不明白:
- 昨天工作得很好……我什么也没做。那么,为什么 Paperclip 突然无法获取正确的 URL?
-
Open-Uri-redirections 的说明给出了以下示例:
open('http://github.com', :allow_redirections => :safe)
我将如何与上面的代码进行协调?
【问题讨论】:
-
我也是同样的错误,昨天还在工作哈哈哈
标签: facebook redirect ruby-on-rails-3.2 open-uri