2

I am trying to have devise redirect to a custom page after registration. It is not working. I have the following custom registrations controller:

class RegistrationsController < Devise::RegistrationsController
  protected

  puts 'Registrations controller is happening"

  def after_sign_up_path_for(resource)
     puts 'after_sign_up_path_for is working'
    "http://www.google.com" 
  end

  def after_inactive_sign_up_path_for(resource)
    puts 'after_inactive_sign_up_path_for is working'
   "http://www.google.com" 
  end
end

And here is my custom routes:

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

So what is interesting is that the registration controller is working, because the first puts statement shows up in the server logs. However, the second and third put statements (inside the after_sign_up_path_for and after_inactive_sign_up_path_for) are not appearing.

How can I get a redirect after registering to work?

Philip7899
  • 4,599
  • 4
  • 55
  • 114

1 Answers1

0

I would suggest you to move those helpers to ApplicationController(see docs) and put them in public namespace.

Rustam Gasanov
  • 15,290
  • 8
  • 59
  • 72
  • Thanks, but i don't think that would be efficient since it should not go through the method after with every controller action like it would if it were in the applications controller. That is only for going back to certain pages. This method should only be seen when the user is trying to register. Atleast that is what I am getting from these focus: https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration) – Philip7899 Feb 10 '14 at 18:32
  • I tried doing it, but it still didn't work. – Philip7899 Feb 10 '14 at 18:34
  • another difference I see in routes, did you try `:registrations => 'registrations'`? string value I mean? – Rustam Gasanov Feb 10 '14 at 18:41
  • 1
    Thanks, tried that but didn't work. I don't think its an issue with routes because the first puts statement is being executed, so the route must be telling it to go there. I think it has something to do with the after_sign_up method. – Philip7899 Feb 10 '14 at 18:43