3

如何使用rails devise gem成功注册后重定向到特定页面?

4

3 回答 3

5

此页面适合您: http: //github.com/plataformatec/devise/wiki/How-To :-Redirect-to-a-specific-page-on-successful-sign-in

于 2010-10-07T11:48:39.690 回答
2

我希望为时不晚,您需要覆盖注册控制器的 after_sign_up_path_for,在您的应用程序/控制器中创建一个registrations_controller.rb,并覆盖上述操作。

注册控制器.rb

class RegistrationsController < Devise::RegistrationsController

  def after_sign_up_path_for(resource)
    ...path of choice...
  end

end

尚未测试此代码,因此可能无法仅使用复制和粘贴。如果您查看此处,它将为您提供您需要的任何其他重定向的操作。

https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb

于 2010-11-23T02:53:57.727 回答
0

wiki 页面最近移动,信息在这里: https ://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in-and-登出

于 2019-05-07T02:43:14.127 回答