Rails中的奇怪DoubleRenderError 3

时间:2010-09-02 08:14:46

标签: ruby-on-rails ruby-on-rails-3

我正在尝试标准的redirect_to some_path and return语法,但出于某种原因,Rails 3并不喜欢这个。

class MyController < ApplicationController
  def some_action
    redirect_to "http://www.google.com"
    return
  end
end

给我标准的错误讯息:

Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

它引用了错误中redirect_to "http://www.google.com"的确切行。无法弄清楚这是怎么可能的!

我已经评论过所有可以找到的过滤器,没有区别。

这是Rails 3.0.0

1 个答案:

答案 0 :(得分:8)

哦,伙计 - 终于明白了。

我把some_action放在上面我实际上已经命名了方法status。显然这是一个保留的单词或rails中的东西,因为它是从其他地方调用它 - 因此DoubleRender错误。

哇 - 这让我花了更长的时间才能解决问题。