Permalink
Browse files

use arel ast construction rather than generating strings

  • Loading branch information...
1 parent 35a2255 commit e468a62dc89d4d3c2a16a6d3e8fd78342a2732df @tenderlove tenderlove committed Jan 5, 2011
@@ -68,7 +68,13 @@ def delete_records(records)
end
def construct_joins
- "INNER JOIN #{@owner.connection.quote_table_name @reflection.options[:join_table]} ON #{@reflection.quoted_table_name}.#{@reflection.klass.primary_key} = #{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.association_foreign_key}"
+ right = join_table
+ left = @reflection.klass.arel_table
+
+ condition = left[@reflection.klass.primary_key].eq(
+ right[@reflection.association_foreign_key])
+
+ right.create_join(right, right.create_on(condition))
end
def join_table

0 comments on commit e468a62

Please sign in to comment.