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.
Summary
Generates additionnal has_many for each given association scope.
Other Information
In my rails projects, I write a lot of
has_many
variations to be able to use fine-grained preload. Eg:Author.all.preload(:published_post)…
. So I wrote this feature to have syntaxic sugar to shorten all theseshas_many
.Here is an unpublished post I wrote about this feature:
https://medium.com/octoly-tech/activerecord-has-many-compose-option-4f2cbdb524a3
Perhaps a better name for this option may be
preloadable_scopes
—it does not cover all things one can do with this feature, but it is a quite self-explained option name since preloading theses generated has_many would be (I think) its main usage. I am not a native english and this is my first contribution, do not hesitate suggesting other option names.