0

I have two devise forms used in my Ruby on rails site...how can i set different route paths for both devise form..i tried to override the after_sign_up_path..but both the forms gets redirected to same path...

I want to set different paths for each form.

Registrations Controller

class Registrations Controller < Devise::Registrations Controller
  protected

  def after_sign_up_path_for(resource)
    'root_path'
  end
end
Cœur
  • 34,719
  • 24
  • 185
  • 251
ganesh
  • 87
  • 11

3 Answers3

2

this method calls when signup is success, so set your after signed up path here

 def after_sign_up_path_for(resource)
      if resource.invitation_type == "first" (please replace with actual invitation type here)
        user1_path(replace with actual path) 
      elsif resource.invitation_type == "second" (please replace with actual invitation type here)
       user2_path(replace with actual path)
      else
        root_path
      end
    end

Hope this helps!

LHH
  • 3,090
  • 1
  • 20
  • 25
0

Inside the application controller, put the code for after_sign_up_path_for path

#put these code inside applications_controller
def after_sign_up_path_for
   if #{your_specific_condition}

   else
    root_path
   end
end
Sanjiv
  • 723
  • 5
  • 12
0

You must be aware that if you want to override your registrations controller, you'll have to include the new controller in your routes:

#config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}
Community
  • 1
  • 1
Richard Peck
  • 74,781
  • 9
  • 90
  • 142