这是一个类似于我的代码。我需要做的是从嵌套方法重定向到其他页面并停止执行它调用的所有操作。在这种情况下,它是方法 2。它应该重定向到'/home/index'
,我需要防止重定向到'/home/index123'
class MyController::ApplicationController
def index
#some work
method1
#some work that must be done if there is no redirect
#some work that must be done if there is no redirect
redirect_to '/home/index123'
end
private
def method1
#some work
method2
#some work that must be done if there is no redirect
#some work that must be done if there is no redirect
end
def method2
#some work
#I need to redirect to other page just from here!
redirect_to '/home/index'
end
end
你的想法?