这是我的注册控制器(覆盖after_sign_up_path_for
方法):
class RegistrationsController < Devise::RegistrationsController
protected
def after_sign_up_path_for(resource)
redirect_to xxxx_path
end
end
我收到以下错误:
AbstractController::DoubleRenderError (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".)
答案 0 :(得分:2)
您的问题在重定向中,在方法中只需编写foo_path
而不是redirect_to foo_path
您的代码应如下所示 的 registrations_controller.rb 强>
class RegistrationsController < Devise::RegistrationsController
def after_sign_up_path_for(resource)
foo_path
end
end
这可以解决您的问题。