Skip to content
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

MONGOID-5829 Add a way to ignore paths for model loading (backport to 9.0-stable) #5905

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Nov 20, 2024

(Backporting from master to 9.0-stable.)

When using Mongoid.load_models, it will blindly try to load all Ruby files in the model load path. This can fail when the loader tries to load files (like concerns) that do not define models, but which reference models that have not yet been loaded.

This PR attempts to address this by adding a new ignore_patterns option, which defaults to an array with a single string, */concerns/*. Any path that matches this pattern will be ignored by the loader.

This lets us exclude the `/concerns/` subdirectory that Rails
promotes. Loading the concerns explicitly leads to load errors when
the concerns reference a model that hasn't been loaded yet.
@jamis jamis changed the title MONGOID-5829 Add a way to ignore paths for model loading MONGOID-5829 Add a way to ignore paths for model loading (backport to 9.0-stable) Nov 20, 2024
@jamis jamis merged commit fde698f into mongodb:9.0-stable Nov 20, 2024
65 of 67 checks passed
@jamis jamis deleted the 5829-add-ignore_patterns-9.0 branch November 20, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants