Skip to content

Allow early configuration of devise models#5853

Open
kaisq wants to merge 1 commit into
heartcombo:mainfrom
kaisq:devise-model-registration
Open

Allow early configuration of devise models#5853
kaisq wants to merge 1 commit into
heartcombo:mainfrom
kaisq:devise-model-registration

Conversation

@kaisq

@kaisq kaisq commented Jun 25, 2026

Copy link
Copy Markdown

As of Rails 8, which enables lazy-loaded routes by default, Devise configuration particularly in test environments consistently breaks because tests begin running before routes have been loaded. This causes Devise (and therefore Warden) to operate with only partial configuration, particularly, a stale default_scope among other things.

This change includes a new method to create a skeleton Mapping object which can be used to indicate a Devise-enabled model class that will be used for authentication before the route loading step has been completed. This object will have its configuration finalized once routes have been completed, and the Devise routes for that object are properly drawn.

This is backwards compatible with the current route-centric configuration.

As of Rails 8, which enables lazy-loaded routes by default, Devise
configuration particularly in test environments consistently breaks
because tests begin running before routes have been loaded. This causes
Devise (and therefore Warden) to operate with only partial
configuration, particularly, a stale default_scope among other things.

This change includes a new method to create a skeleton Mapping object
which can be used to indicate a Devise-enabled model class that will be
used for authentication before the route loading step has been
completed. This object will have its configuration finalized once routes
have been completed, and the Devise routes for that object are properly
drawn.

This is backwards compatible with the current route-centric
configuration.
@kaisq

kaisq commented Jun 25, 2026

Copy link
Copy Markdown
Author

This would fix #5752 (I have tested this locally with code that I believe to be hitting the same error) and likely also fixes #5844 (though I do not currently have a broken example of this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant