Add #all_includes
method to reflections
`yield` instead of relying on checking if the reflection is equal to the `chain_head`.
This commit is contained in:
parent
0408e212ca
commit
96e277c03b
@ -121,6 +121,8 @@ def initialize(reflection, alias_name)
|
||||
super(reflection)
|
||||
@alias_name = alias_name
|
||||
end
|
||||
|
||||
def all_includes; nil; end
|
||||
end
|
||||
|
||||
def get_chain(refl, association, tracker)
|
||||
@ -161,7 +163,7 @@ def add_constraints(scope, owner, assoc_klass, refl, connection, chain_head, cha
|
||||
scope.merge! item.except(:where, :includes, :bind)
|
||||
end
|
||||
|
||||
if reflection == chain_head
|
||||
reflection.all_includes do
|
||||
scope.includes! item.includes_values
|
||||
end
|
||||
|
||||
|
@ -970,6 +970,8 @@ def alias_candidate(name)
|
||||
def alias_name
|
||||
Arel::Table.new(table_name)
|
||||
end
|
||||
|
||||
def all_includes; yield; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user