From 85fe5edcec77f96923ed4f4e8b63a247ebe6b055 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Jul 2013 13:41:24 -0700 Subject: decouple the manager class from building join constraints --- .../associations/join_dependency/join_association.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 ee1fcc17d8..3205cd41a2 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -64,7 +64,8 @@ module ActiveRecord end end - def join_to(manager) + def join_constraints + joins = [] tables = @tables.dup foreign_table = parent_table @@ -84,11 +85,10 @@ module ActiveRecord foreign_key = reflection.foreign_key when :has_and_belongs_to_many # Join the join table first... - manager.from(join( + joins << join( table, table[reflection.foreign_key]. - eq(foreign_table[reflection.active_record_primary_key]) - )) + eq(foreign_table[reflection.active_record_primary_key])) foreign_table, table = table, tables.shift @@ -125,13 +125,13 @@ module ActiveRecord constraint = constraint.and rel.arel.constraints end - manager.from(join(table, constraint)) + joins << join(table, constraint) # The current table in this iteration becomes the foreign table in the next foreign_table, foreign_klass = table, klass end - manager + joins end # Builds equality condition. -- cgit v1.2.3