简体   繁体   中英

Redirect user to certain page after registration using Devise + confirmable

I am using Devise for user registration, and am using Confirmable to perform email validation.

After a user registers, I want to redirect them to a URL explaining that they need to check their email and click on the link sent. I am using Devise's :authenticate_user! method to ensure users log in before seeing site content.

Per this file , it looks like I can define a after_inactive_sign_up_path_for(resource) and a after_sign_up_path_for(resource) to control this redirect.

Here is my application controller:

class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!, :except => [:after_inactive_sign_up_path_for,     :after_sign_up_path_for]

def after_sign_up_path_for(user)
  confirm_path
end

def after_inactive_sign_up_path_for(user)
  confirm_path
end

end 

But it doesn't work. confirm_path is in my static_pages controller, which is accessible without signin as I have skip_before_filter :authenticate_user! included

When a user registers, the :authenticate_user! helper kicks in and redirects to the login page.

Have you tried overriding the registration controller like so :

class RegistrationsController < Devise::RegistrationsController
  protected

  def after_inactive_sign_up_path_for(resource)
    '/an/example/path'
  end
end

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM