Denys Medynskyi
Denys Medynskyi

Reputation: 2353

After sign_in/up redirection trouble with devise

I want after login user redirects to page creating new table(website), so I have function in my ApplicationController:

def after_sign_in_path_for(resource)
 new_website_path 
end

and after registration I want user redirects to his edit page:

def after_sign_up_path_for(resource)
 edit_user_registration_path
end

So the question is - why it doesn't work ?

Upvotes: 1

Views: 147

Answers (2)

Denys Medynskyi
Denys Medynskyi

Reputation: 2353

So I changed access level like this:

 class RegistrationsController < Devise::RegistrationsController
 protected
   def after_sign_up_path_for(resource)
    edit_user_registration_path
   end
 protected
  def after_sign_in_path_for(resource)
    new_website_path
   end
  end

Before this at it was working for after_sign_in and after_sign_out and now it doesn't wor at all. Why ?

Upvotes: 0

janders223
janders223

Reputation: 3153

This is because after_sign_up_path_for(resource) is a protected method of the Devise registrations controller as you can see in the controller. The only way you will be able to get a custom redirect after sign up, is to override the Devise registrations controller on your own. There are instructions on doing so on the Devise Wiki.

Upvotes: 1

Related Questions