aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/belongs_to.rb
diff options
context:
space:
mode:
authorIan Young <ian.greenleaf@gmail.com>2012-09-17 14:57:13 -0700
committerIan Young <ian.greenleaf@gmail.com>2013-03-20 13:43:07 -0700
commit66679c8ecd9e916cbd96745b853603bc2fed7639 (patch)
tree7b0b2f5b91aa7e48db3beb7d184922be55d37f5c /activerecord/lib/active_record/associations/builder/belongs_to.rb
parent34c7e73c1def1312e59ef1f334586ff2f668246e (diff)
downloadrails-66679c8ecd9e916cbd96745b853603bc2fed7639.tar.gz
rails-66679c8ecd9e916cbd96745b853603bc2fed7639.tar.bz2
rails-66679c8ecd9e916cbd96745b853603bc2fed7639.zip
Update other counter caches on destroy
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/belongs_to.rb')
-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