Update `ActionDispatch::Routing::Mapper:Scoping#constraints` documentation
Created by: stevepolitodesign
Motivation / Background
The previous recommendation to place constraints in lib/constraints
did not work in practice on a default Rails install, as it will raise the following:
uninitialized constant Iphone (NameError)
Instead, recommend placing constraints in app/constraints
such that they will be eager loaded.
Additional information
Alternatively, we could update the documentation to elaborate that lib/constraints
would need to be explicitly eager loaded.
config.eager_load_paths << Rails.root.join("lib/constraints")
Checklist
Before submitting the PR make sure the following are checked:
-
This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs. -
Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
-
Tests are added or updated if you fix a bug or add a feature. -
CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.