You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor ActiveRecord::TokenFor to not rely on relation delegation
Ref: rails#50396
Ref: rails#51776
`ActiveRecord::Relation` automatically delegates missing methods
to the model class wrapped in a `scoping { }` block.
This is to support scoping in user defined class methods. The problem
however is that it's very error prone for the framework, because we
can mistakenly call model methods from inside `Relation` and not
realized we're applying a global scope.
In the best case scenario it's just a waste of performance, but
it can also lead to bugs like rails#51775
I'm planning to restrict this automatic delegation to methods defined
in childs of `ActiveRecord::Base` only: rails#50396
but for this to work we must first refactor any Rails code that rely on it.
0 commit comments