aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-31 20:00:24 +0000
committerJon Leighton <j@jonathanleighton.com>2010-12-31 20:00:45 +0000
commit12675988813e82ac30f7c0e0008c12c4cf5d8cdc (patch)
tree2856d3a21a139d0c182fc5a99724dc49e39d7eb5 /activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
parent3c400627eb9cfac380d716ccf1182d61db4a45a6 (diff)
downloadrails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.tar.gz
rails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.tar.bz2
rails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.zip
Rename AssociationReflection#primary_key_name to foreign_key, since the options key which it relates to is :foreign_key
Diffstat (limited to 'activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index b1d454545f..5336b6cc28 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -40,7 +40,7 @@ module ActiveRecord
attributes = columns.map do |column|
name = column.name
value = case name.to_s
- when @reflection.primary_key_name.to_s
+ when @reflection.foreign_key.to_s
@owner.id
when @reflection.association_foreign_key.to_s
record.id
@@ -64,7 +64,7 @@ module ActiveRecord
records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) }
else
relation = Arel::Table.new(@reflection.options[:join_table])
- stmt = relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
+ stmt = relation.where(relation[@reflection.foreign_key].eq(@owner.id).
and(relation[@reflection.association_foreign_key].in(records.map { |x| x.id }.compact))
).compile_delete
@owner.connection.delete stmt.to_sql