From d29399061e54092fdbf57780c38e19dd1921f45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 23 May 2013 06:58:10 -0700 Subject: Merge pull request #10713 from senny/10693_fix_primary_key_option_on_has_many Fix the `:primary_key` option for `has_many` associations. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/associations/has_many_association.rb --- activerecord/lib/active_record/associations/has_many_association.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 059e6c77bc..dab57bab88 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -89,8 +89,7 @@ module ActiveRecord records.each { |r| r.destroy } update_counter(-records.length) unless inverse_updates_counter_cache? else - keys = records.map { |r| r[reflection.association_primary_key] } - scope = scoped.where(reflection.association_primary_key => keys) + scope = self.scope.where(reflection.klass.primary_key => records) if method == :delete_all update_counter(-scope.delete_all) -- cgit v1.2.3