改变设计注册路径

时间:2014-11-05 17:51:06

标签: ruby-on-rails redirect devise sign

我需要将用户重定向到除根页

之外的单独页面

这是我的注册控制器(覆盖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".)

1 个答案:

答案 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

这可以解决您的问题。