aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMatthew Robertson <matthewrobertson03@gmail.com>2012-12-01 17:56:28 -0800
committerMatthew Robertson <matthew@cloudclinic.ca>2013-02-13 16:01:58 -0800
commit18ffe50581f41a4f24d791e42826c977276a0df3 (patch)
tree61c2b013ddf8b5eb22c59e1f5ee9c1c3dfc938fd /activerecord/lib
parentc0022f8d885d5cca8a7f7d3d64c60af1e04684ea (diff)
downloadrails-18ffe50581f41a4f24d791e42826c977276a0df3.tar.gz
rails-18ffe50581f41a4f24d791e42826c977276a0df3.tar.bz2
rails-18ffe50581f41a4f24d791e42826c977276a0df3.zip
backport of fix for issue #7630
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 53d49fef2e..2b9e7ea55d 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -139,6 +139,11 @@ module ActiveRecord
delete_through_records(records)
+ if source_reflection.options[:counter_cache]
+ counter = source_reflection.counter_cache_column
+ klass.decrement_counter counter, records.map(&:id)
+ end
+
if through_reflection.macro == :has_many && update_through_counter?(method)
update_counter(-count, through_reflection)
end