ganesh ganesh - 2 months ago 12
Ruby Question

Devise Registration Form

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

LHH LHH
Answer Source

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!