Currently only the top level scope is being yielded to the block. This
is un-intuitive in case of deeply nested associations and
has_many...through relationships.
class Parent
has_many :children
has_many :grand_children, through: children
end
class Child
belongs_to :parent
has_many :grand_children
end
class GrandChild
belongs_to :child
end
Parent.where_exists(:grand_children) do |assoc_scope|
print assoc_scope.class # => Child::ActiveRecord_Relation # Should be GrandChild::ActiveRecord_Relation
end
Currently only the top level scope is being yielded to the block. This is un-intuitive in case of deeply nested associations and has_many...through relationships.