Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to correct Error 401 Unauthorized, using a multiple devise model ?

Clément NICOLAS asked in Rails

I'm doing a mini-project, for which I'm using two devise models, a user model and a advisor model. When I log in as an advisor, I'm redirected to a 'pages_advisors' page. On this page, there's a link 'create a new appointment type' which should redirect me to new_advisor_appointment_type. Instead, it redirects me to 'user sign in'. In my AppointmentTypes Controller I've put a before_action :authenticate_advisor!. My routes seem correct. When I look at the logs, the message is as follows: Started GET "/advisors/2/appointment_types/new" for 127.0.0.1 at 2024-01-18 00:09:45 +0100
Processing by AppointmentTypesController#new as HTML
Parameters: {"advisor_id"=>"2"}
Completed 401 Unauthorized in 8ms (ActiveRecord: 0.0ms | Allocations: 523). I've searched everywhere, asked chatgpt, can't find a solution... There seems to be a conflict in session management.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.