mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-08 23:28:00 -05:00
Merge pull request #5728 from heartcombo/lazy-routes-fix
Make Devise.mappings work with lazy loaded routes.
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
* enhancements
|
||||
* Removed deprecations warning output for `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` (@soartec-lab)
|
||||
* Add Rails 8 support.
|
||||
- Routes are lazy-loaded by default in test and development environments now so Devise loads them before `Devise.mappings` call.
|
||||
|
||||
Please check [4-stable](https://github.com/heartcombo/devise/blob/4-stable/CHANGELOG.md)
|
||||
for previous changes.
|
||||
|
||||
@@ -274,8 +274,14 @@ module Devise
|
||||
# PRIVATE CONFIGURATION
|
||||
|
||||
# Store scopes mappings.
|
||||
mattr_reader :mappings
|
||||
@@mappings = {}
|
||||
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
|
||||
|
||||
# OmniAuth configurations.
|
||||
mattr_reader :omniauth_configs
|
||||
|
||||
Reference in New Issue
Block a user