aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2013-03-20 15:51:30 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2013-03-20 15:51:30 -0700
commit70d0537d5550958d7e006787de869ce9046101fc (patch)
tree121d61ad1bc38b739f0434d4f808c8dd09ef8d9c /activerecord/lib/active_record/associations/builder
parent066907d1cb3e7e390287dff9c324a4091d76a97b (diff)
parent66679c8ecd9e916cbd96745b853603bc2fed7639 (diff)
downloadrails-70d0537d5550958d7e006787de869ce9046101fc.tar.gz
rails-70d0537d5550958d7e006787de869ce9046101fc.tar.bz2
rails-70d0537d5550958d7e006787de869ce9046101fc.zip
Merge pull request #7706 from iangreenleaf/multiple_counter_caches
Update other counter caches on destroy
Diffstat (limited to 'activerecord/lib/active_record/associations/builder')
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb
index fbcb21118d..9ac561b997 100644
--- a/activerecord/lib/active_record/associations/builder/belongs_to.rb
+++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -31,7 +31,7 @@ module ActiveRecord::Associations::Builder
end
def belongs_to_counter_cache_before_destroy_for_#{name}
- unless marked_for_destruction?
+ unless destroyed_by_association && destroyed_by_association.foreign_key.to_sym == #{foreign_key.to_sym.inspect}
record = #{name}
record.class.decrement_counter(:#{cache_column}, record.id) unless record.nil?
end