Permalink
Browse files

pass the foreign table and class to the join_constraints method

  • Loading branch information...
1 parent bae5e02 commit e7bb4bb072b16a715b0a0346b5b127b7c957fae8 @tenderlove tenderlove committed Oct 20, 2013
@@ -166,7 +166,9 @@ def instantiate(result_set, aliases)
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
@@ -25,13 +25,10 @@ def match?(other)
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

0 comments on commit e7bb4bb

Please sign in to comment.