diff options
author | Emilio Tagua <miloops@gmail.com> | 2008-12-02 14:12:09 -0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-12-10 10:59:52 -0800 |
commit | 05f2183747c8e75c9e8bbaadb9573b4bdf41ecfc (patch) | |
tree | 6286202b3884a8b20be2f027ce76a49642143cc9 /activerecord/lib/active_record/associations/association_collection.rb | |
parent | 355f41d8aafd75d76db25cdda4736e0052b0605c (diff) | |
download | rails-05f2183747c8e75c9e8bbaadb9573b4bdf41ecfc.tar.gz rails-05f2183747c8e75c9e8bbaadb9573b4bdf41ecfc.tar.bz2 rails-05f2183747c8e75c9e8bbaadb9573b4bdf41ecfc.zip |
Fix: counter_cache should decrement on deleting associated records.
[#1195 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/associations/association_collection.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 0ff91fbdf8..0ad58010b2 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -202,6 +202,9 @@ module ActiveRecord records.each do |record| @target.delete(record) + if respond_to?(:cached_counter_attribute_name) && @owner[cached_counter_attribute_name] + @owner.class.decrement_counter(cached_counter_attribute_name, @owner.send(@owner.class.primary_key)) + end callback(:after_remove, record) end end |