ruby-on-rails – Rails 3中的奇怪DoubleRenderError
发布时间:2020-12-17 02:51:24 所属栏目:百科 来源:网络整理
导读:我正在尝试使用标准redirect_to some_path并返回语法,但出于某种原因,Rails 3并不喜欢这个. class MyController ApplicationController def some_action redirect_to "http://www.google.com" return endend 给我标准的错误信息: Render and/or redirect we
我正在尝试使用标准redirect_to some_path并返回语法,但出于某种原因,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 解决方法
哦,男人 – 终于明白了.
我在上面放了some_action,我实际上已经命名了方法状态.显然这是一个保留的单词或rails中的东西,因为它是从其他地方调用它 – 因此DoubleRender错误. 哇 – 这让我花了更长的时间才能解决问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |