我正在寻找关于行为的一些澄清redirect_to.
我有这个代码:
if some_condition
redirect_to(path_one)
end
redirect_to(path_two)
Run Code Online (Sandbox Code Playgroud)
如果some_condition == true我收到此错误:
在此操作中多次调用渲染和/或重定向.请注意,您只能调用渲染或重定向,每次操作最多一次.
似乎该方法在redirect_to调用后继续执行.我需要编写这样的代码:
if some_condition
redirect_to(path_one)
return
end
redirect_to(path_two)
Run Code Online (Sandbox Code Playgroud)