How to make Devise redirect after confirmation

后端 未结 6 812
囚心锁ツ
囚心锁ツ 2020-12-02 13:07

How can I create an after-confirmation redirect in Devise?

Before I added the confirmation module the custom after_sign_up_path worked fine

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 13:57

    Have you checked the Devise wiki? It explains how to do this, with the after_signup_path_for being the path to define in your case.

    From the wiki:

    Make a new controller "registrations_controller.rb" and customize the appropriate method:

    class RegistrationsController < Devise::RegistrationsController
      protected
    
      def after_sign_up_path_for(resource)
        '/an/example/path'
      end
    end
    

    Then add a route to use it:

    Modify config/routes.rb to use the new controller

    devise_for :users, :controllers => { :registrations => "registrations" }
    

提交回复
热议问题