【发布时间】:2011-08-04 13:08:07
【问题描述】:
我总是收到以下错误:
AbstractController::DoubleRenderError(渲染和/或重定向是 在此操作中多次调用。请注意,您只能 调用渲染或重定向,每个操作最多一次。另请注意 既不重定向也不渲染终止动作的执行,所以如果 你想在重定向后退出一个动作,你需要做一些事情 比如“redirect_to(...) and return”。):
第一次 id 为 nil 时发生错误,但第二次不是...
def calc_next
id = next()
if id.nil?
id = next_next()
if id.nil?
render :layout => false, :format => :js
else
redirect_to :action => "view", :id => id, :format => :js
end
else
redirect_to :action => "view", :id => id, :format => :js
end
end
我没有看到这个重定向的问题,因为外部的很好。即使使用调试器,也不会同时进行两个重定向...
感谢任何帮助... 马库斯
【问题讨论】: