Search code examples
ruby-on-railsdevise

Devise after_sign_up_path_for not being called


I am using Devise with multiple models for authentication, Admin and User. On a User signup I want to redirect to a profile page. (Admins are created using a rake task, or through the admin Admin pages, not by going through a registration process.)

I am using Ruby 2.0.0, Rails 4, and Devise 3.1.0.

This is the code I am using to do the redirect, as per help here on StackOverflow and on the Devise GitHub page.

class ApplicationController < ActionController::Base
    protect_from_forgery
    before_filter :authenticate_user!

    def after_sign_up_path_for(resource)
        Rails.logger.info('ApplicationController: after_sign_up_path_for called')
        '/profile'
    end

    def after_inactive_sign_up_path_for(resource)
        Rails.logger.info('ApplicationController: after_inactive_sign_up_path_for called')
        '/profile'
    end
end

However, when I run the through the signup, it appears that neither the after_sign_up or the after_inactive_sign_up methods are called, as no logging appears.

Now I've done some hunting around and I can't seem to find anything wrong with my code. I am wondering if it is due to the multiple model model I am using.

Can anyone shed some light on this?

If you need to see more code or other info, please ask.


Solution

  • Read the devise wiki on github.

    Here is the related link

    https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in,-sign-up,-or-sign-out