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 #5904

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Nov 19, 2024

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 requested a review from comandeo-mongo November 19, 2024 23:03
@jamis jamis merged commit c72e43f into mongodb:master Nov 20, 2024
65 of 67 checks passed
@jamis jamis deleted the 5829-add-ignore_patterns branch November 20, 2024 15:14
jamis added a commit to jamis/mongoid that referenced this pull request Nov 20, 2024
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 added a commit that referenced this pull request Nov 20, 2024
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.
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