Uninitialized constant Devise::SessionsController
when extending controller
#8160
-
Issue happens when changing Rails version from 6.x to 7.x
Simply having this file produces an error with rails 7.x
Seems to be related to the loading process, but this setup works with rails 6.x and zeitwerk enabled 🤔 Reproduced with blank Rails app rails 7.1.2 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
update: The custom controller code does register if I
Not sure if this a proper solution here or simply a walk around. Also not sure if I am restricted to have the code under Would appreciate any suggestions. |
Beta Was this translation helpful? Give feedback.
-
A few things to note. I believe the approach has to be All I can do is share what I've done in my app for a long time now and it works fine with Rails 7 and Zeitwerk. Also, I think this would be preferred since you'd want to customize most things like the view too. We take this approach to use Okta for admin login. In routes, declare the new sessions controller: devise_for :admin_users, ActiveAdmin::Devise.config.merge(
controllers: {
sessions: 'active_admin/sessions',
# ...
}
) Then declare a controller in class ActiveAdmin::SessionsController < ActiveAdmin::Devise::SessionsController
# ...
end From there it should be ok. |
Beta Was this translation helpful? Give feedback.
-
Awesome, thanks for the prompt response. Your suggested solution works well for me. It seems that simply having any |
Beta Was this translation helpful? Give feedback.
A few things to note. I believe the approach has to be
class ActiveAdmin::Devise::SessionsController
instead of a module with Zeitwerk but not sure if that will help much based on the Rails guide. It could be that it occurs because those files are in ourlib
and not in theapp
folder so I wonder if related to that. I've seen past issues bring this up.All I can do is share what I've done in my app for a long time now and it works fine with Rails 7 and Zeitwerk. Also, I think this would be preferred since you'd want to customize most things like the view too. We take this approach to use Okta for admin login.
In routes, declare the new sessions controller: