Generate delegation methods to named scope in the definition time #34122
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.
The delegation methods to named scope are defined when
method_missing
is invoked on the relation.
Since #29301, the receiver in the named scope is changed to the relation
like others (e.g.
default_scope
, etc) for consistency.Most named scopes would be delegated from relation by
method_missing
,since we don't allow scopes to be defined which conflict with instance
methods on
Relation
(#31179). But if a named scope is defined with thesame name as any method on the
superclass
(e.g.Kernel.open
), themethod_missing
on the relation is not invoked.To address the issue, make the delegation methods to named scope is
generated in the definition time.
Fixes #34098.