【问题标题】:This webpage has a redirect loop - Rails这个网页有一个重定向循环 - Rails
【发布时间】:2014-12-27 21:11:00
【问题描述】:

我正在尝试让我的应用在遇到错误时重定向到自定义路由:

Twitter::Error::TooManyRequests

但是,由于某种原因,我遇到了困难,并且不断收到此错误:

This webpage has a redirect loop

这是我的控制器:

#app/controllers/tweets_controller.rb

rescue_from Twitter::Error::TooManyRequests, with: :too_many_requests

    def too_many_requests

        redirect_to too_many_requests_path

    end

这是我的路线:

#config/routes.rb

get "/too_many_requests", to: "tweets#too_many_requests", as: :too_many_requests

我在app/views/tweets 中有一个名为too_many_requests.html.erb 的视图

我知道我一定做错了什么,但有人可以帮忙吗?

谢谢

【问题讨论】:

  • 大概你的too_many_requests.html.erb 在某处有你的推特订阅源。
  • 这就是我的想法,但too_many_requests.html.erb 目前是空的

标签: ruby-on-rails ruby-on-rails-4 twitter twitter-gem


【解决方案1】:

除非我遗漏了什么,否则看起来您将操作重定向到自身:

def too_many_requests
  # Error handling.....

  # You should redirect this elsewhere
  redirect_to some_other_path
end

【讨论】:

  • 哇!你说得对,傻我,谢谢你看
猜你喜欢
  • 1970-01-01
  • 2013-11-10
  • 2013-06-10
  • 2013-12-22
  • 2013-11-06
  • 2013-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多