diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2014-04-14 14:55:34 -0400 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2014-04-14 14:55:34 -0400 |
commit | 7e28b4ed9a1dbd131877cf784aad7ace49073a52 (patch) | |
tree | 6c3e3cee6574e6a5a7cf1954a81954f0df8c6045 /activerecord/lib/active_record/associations/builder | |
parent | 109d1b2b10ac8b602b6a1a9995c3fd9c63aefa22 (diff) | |
download | rails-7e28b4ed9a1dbd131877cf784aad7ace49073a52.tar.gz rails-7e28b4ed9a1dbd131877cf784aad7ace49073a52.tar.bz2 rails-7e28b4ed9a1dbd131877cf784aad7ace49073a52.zip |
Use inheritance chain instead of callbacks to increment counter caches after destroy
Diffstat (limited to 'activerecord/lib/active_record/associations/builder')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index bd2ee1a929..7614fdd97f 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -30,18 +30,6 @@ module ActiveRecord::Associations::Builder mixin.class_eval do - def belongs_to_counter_cache_after_destroy(reflection) - foreign_key = reflection.foreign_key.to_sym - unless destroyed_by_association && destroyed_by_association.foreign_key.to_sym == foreign_key - record = send reflection.name - if record && self.actually_destroyed? - cache_column = reflection.counter_cache_column - record.class.decrement_counter(cache_column, record.id) - self.clear_destroy_state - end - end - end - def belongs_to_counter_cache_after_update(reflection) foreign_key = reflection.foreign_key cache_column = reflection.counter_cache_column @@ -67,10 +55,6 @@ module ActiveRecord::Associations::Builder def self.add_counter_cache_callbacks(model, reflection) cache_column = reflection.counter_cache_column - model.after_destroy lambda { |record| - record.belongs_to_counter_cache_after_destroy(reflection) - } - model.after_update lambda { |record| record.belongs_to_counter_cache_after_update(reflection) } |