我有这个代码用于从Facebook获取头像...
if auth.info.image.present?
user.update_attribute(:avatar, URI.parse(auth.info.image))
end
Run Code Online (Sandbox Code Playgroud)
当我尝试加载代码时,我收到此错误:
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'
Run Code Online (Sandbox Code Playgroud)
我知道这是Open-URI不允许HTTP到HTTPS重定向的问题...我明白这可以用Open-Uri-Redirections插件解决https://github.com/jaimeiniesta/open_uri_redirections
但有两件事我不明白:
Open-Uri-redirections的说明给出了以下示例:
打开(' http ://github.com',:allow_redirections =>:safe)
我如何将其与上面的代码进行协调?