我需要将用户重定向到除根页面之外的单独页面
这是我的注册 Controller (覆盖 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".)
最佳答案
您的问题在于重定向,在方法中只需编写 foo_path
而不是 redirect_to foo_path
您的代码应如下所示 registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def after_sign_up_path_for(resource)
foo_path
end
end
这应该可以解决您的问题。
关于ruby-on-rails - 更改设备注册路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26763805/