2
votes

I am using Rails 4.0.2 and Devise 3.2.2 to handle user registration / authentication.

I need to redirect a user to an an view page immediately after a user signs up for an account. I have try the codes from

https://github.com/plataformatec/devise/wiki/How-To%3a-Redirect-to-a-specific-page-on-successful-sign-up-%28registration%29

but it doesn't work, instead I was redirected to sign in page after I sign up. Pleas see below my codes.

How can I alter devise flow to redirect the user?

Thanks!

This is my RegistrationsController :

class RegistrationsController < Devise::RegistrationsController
  protected

  def after_sign_up_path_for(resource)
    'http://www.google.com'   #to test if i was redirect to google
  end
end

This is my routes.rb :

Application::Application.routes.draw do
  get "registrations/update"
  get "pages/home"
  get "pages/privacy"
  get "pages/terms"

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


  root "pages#home"

end
1
Have you restarted your server?BroiSatse
Is your new account confirmable and not active yet ?Nanego
Yes I have restarted my server.Jimmy
Yes, confirmable and has not been active yet.Jimmy
Anyway, I have fix it by adding def after_inactive_sign_up_path_for(resource) 'http://google.com' end to my RegistrationsController. Thanks BroiSatseJimmy

1 Answers

3
votes

I have fix it by adding

def after_inactive_sign_up_path_for(resource) 
   'http://google.com' 
end 

to my RegistrationsController.

Thanks BroiSatse