-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Devise.mappings work with lazy loaded routes. #5728
Conversation
4b5b263
to
3c05982
Compare
Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments. However, Devise's mappings are built during the routes loading phase. To ensure it works correctly, we need to load the routes first before accessing @@mappings.
3c05982
to
24c4714
Compare
When can we expect a release with this? Thanks |
Main branch is labelled devise version But would it be possible to backport this to a devise 4.x branch and do a 4.x release with it? I too believe I am blocked from a Rails 8 upgrade on this. |
Converting this PR to this patch in a require 'devise'
Devise # make sure it's already loaded
module Devise
def self.mappings
# Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments.
# However, Devise's mappings are built during the routes loading phase.
# To ensure it works correctly, we need to load the routes first before accessing @@mappings.
Rails.application.try(:reload_routes_unless_loaded)
@@mappings
end
end |
Thanks for fix. But looks like the patch isn't enough to make it work, because |
Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments. However, Devise's mappings are built during the routes loading phase. To ensure it works correctly, we need to load the routes first before accessing
@@mappings
.Closes #5705 #5695