Skip to content

Document how to defer schema lookups in Devise models - #5884

Draft
merouaneamqor wants to merge 1 commit into
heartcombo:mainfrom
merouaneamqor:docs/devise-for-schema-lookup
Draft

merouaneamqor wants to merge 1 commit into
heartcombo:mainfrom
merouaneamqor:docs/devise-for-schema-lookup

Conversation

@merouaneamqor

@merouaneamqor merouaneamqor commented Nov 10, 2026 •

Copy link
Copy Markdown

devise_for loads the mapped model while drawing routes. On Rails 7.2, bin/rails db:create can draw routes before creating the database, so a schema lookup in the model's class body raises ActiveRecord::NoDatabaseError.

Document how to defer a schema-backed validation limit until validation runs. This preserves the column limit and leaves Devise's routing behavior unchanged.

Verified with Rails 7.2.4 and MySQL 8.0. The reproduction failed before the model change and passed afterward. It covered database creation, the sign-in route, the email length boundary, and propagation of the missing database error when the model is used. The Devise Active Record suite passed with 878 tests and 2,456 assertions.

Related to #5786.

@merouaneamqor
merouaneamqor marked this pull request as draft November 10, 2026 21:28
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