Eager load models when running erd
#1200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1058
Reading up on voormedia/rails-erd#322,
Zeitwork::Loader.eager_load_all
will ensure all of our application's models will be included when runningbundle exec erd
.There were suggestions to put that line inside
config/environment.rb
, but I ultimately went with this fix which isolates it specifically to the scope of theerd
command.I'm not 100% happy having to include a file like this, but it seems like there still isn't a fix for Rails 7.
With that being said, the command is generating a PDF for the same amount of models (31) before and after this fix. I've decided to submit this PR though so we don't miss anymore models if some are added in the future and aren't captured if we aren't eager loading.
Just for reference, here's the output that I'm getting.
The tests are failing here, but after merging main on a different branch you can see that they're passing.