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
classParent < ActiveRecord::Basehas_many:children,->(){order('id DESC')},dependent: :destroydodefxyzyyx
...
end
...
endend
and a query like this:
Parent.includes(:children).to_a
you get the deprecation warning about instance-depedence:
DEPRECATION WARNING: The association scope 'children' is instance dependent (the scope block takes an argument). Preloading happens before the individual instances are created. This means that there is no instance being passed to the association scope. This will most likely result in broken or incorrect behavior. Joining, Preloading and eager loading of these associations is deprecated and will be removed in the future. (called from test_preloading_of_associations at preloading_test.rb:25)
With an association defined like this:
and a query like this:
you get the deprecation warning about instance-depedence:
which does not seem to be sensible in this case.
Runnable test case:
The culprit seems to be in CollectionAssociation in ActiveRecord::Associations::Builder, the initialize method says:
And wrap_scope is:
With this you end up with scope.arity > 0 even though there is no user-given scope (or the user-given scope actually is of arity 0).
@senny what do you think about this?
The text was updated successfully, but these errors were encountered: