2010-09-02 58 views
4

我正在嘗試標準redirect_to some_path and return語法,但由於某些原因,Rails 3並不喜歡這一點。Rails 3中的奇怪DoubleRenderError 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

回答

8

哦,人 - 終於搞明白了。

我在上面放了some_action我實際上已經命名方法status。顯然這是一個保留字或者是在rails中的東西,因爲它從別的地方調用它 - 因此是DoubleRender錯誤。

哇 - 這讓我花了更多的時間來解決它應該有的問題。

+0

同樣的問題在這裏。該死的和那些保留字。如果只有錯誤會說問題在哪裏...... =) – zigomir 2011-05-20 23:18:55

+0

哇,我希望這是有記錄的,它只是打我壞...只是出現,突然,在生產中,即使我有一個名爲'狀態'的行動,好幾個月! – LisaD 2012-11-10 01:02:27