Reputation: 1
I have two devise models namely user
and technician
. I want technicians
to be directed to a particular page when they login so I implemented it according to the devise tutorial and put this in the application controller
def after_sign_in_path_for(resource)
case resource.class
when technician
new_services_path
when user
root_path
end
end
but I get this error. [![enter image description here][1]][1] what am I missing here?
Upvotes: 0
Views: 321
Reputation: 3477
You can try this.
def after_sign_in_path_for(resource)
case resource.class.name
when "Technician"
new_services_path
when "User"
root_path
end
end
Upvotes: 0
Reputation: 9747
You need to update your switch
. resource.class
will return class of the resource (User
or Technician
). So, you modify your method as follow:
def after_sign_in_path_for(resource)
case resource.class
when Technician
new_services_path
when User
root_path
end
end
Upvotes: 3
Reputation: 15781
Classes are being written with capital letter: Technician
, User
. The following code should work:
def after_sign_in_path_for(resource)
case resource.class
when Technician
new_services_path
when User
root_path
end
end
Upvotes: 1