diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 030049d000..ad7c978ff2 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -166,7 +166,9 @@ module ActiveRecord def make_joins(node) node.children.flat_map { |child| chain = child.reflection.chain - child.join_constraints(node, child.join_type, child.tables, chain) + foreign_table = node.table + foreign_klass = node.base_klass + child.join_constraints(foreign_table, foreign_klass, child.join_type, child.tables, chain) .concat make_joins(child) } end diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 9204fa3a56..926d03e495 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -25,13 +25,10 @@ module ActiveRecord super && reflection == other.reflection end - def join_constraints(parent, join_type, tables, chain) + def join_constraints(foreign_table, foreign_klass, join_type, tables, chain) joins = [] tables = tables.reverse - foreign_table = parent.table - foreign_klass = parent.base_klass - scope_chain_iter = reflection.scope_chain.reverse_each # The chain starts with the target table, but we want to end with it here (makes |