相关疑难解决方法(0)

Rails 3.2.17运行时错误重定向禁止的facebook

我有这个代码用于从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

但有两件事我不明白:

  1. 昨天工作得很好......我什么都没改变.那么,为什么Paperclip突然无法获得正确的URL?
  2. Open-Uri-redirections的说明给出了以下示例:

    打开(' http ://github.com',:allow_redirections =>:safe)

我如何将其与上面的代码进行协调?

redirect facebook open-uri ruby-on-rails-3.2

18
推荐指数
3
解决办法
7897
查看次数

标签 统计

facebook ×1

open-uri ×1

redirect ×1

ruby-on-rails-3.2 ×1