diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-26 06:10:32 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-26 06:10:32 +0900 |
commit | 376ffe0ea2e59dc51461122210729c05a10fb443 (patch) | |
tree | 562db6c3c92c9abc12dcaa2878c599d97fedd85c /activerecord | |
parent | 49f9dff9b6ba1451d8c85927d5f75327bd2322d9 (diff) | |
download | rails-376ffe0ea2e59dc51461122210729c05a10fb443.tar.gz rails-376ffe0ea2e59dc51461122210729c05a10fb443.tar.bz2 rails-376ffe0ea2e59dc51461122210729c05a10fb443.zip |
Remove `counter_cache_target` which is no longer called
`counter_cache_target` is called only when updated counter cache in
replacing target, but it was already removed at #33913.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/belongs_to_association.rb | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index 544aec5e8b..11a89366aa 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -61,11 +61,7 @@ module ActiveRecord def update_counters(by) if require_counter_update? && foreign_key_present? - if target && !stale_target? - target.increment!(reflection.counter_cache_column, by, touch: reflection.options[:touch]) - else - counter_cache_target.update_counters(reflection.counter_cache_column => by, touch: reflection.options[:touch]) - end + reader.increment!(reflection.counter_cache_column, by, touch: reflection.options[:touch]) end end @@ -96,11 +92,6 @@ module ActiveRecord inverse && inverse.has_one? end - def counter_cache_target - primary_key = reflection.association_primary_key(klass) - klass.unscoped.where!(primary_key => owner._read_attribute(reflection.foreign_key)) - end - def stale_state result = owner._read_attribute(reflection.foreign_key) { |n| owner.send(:missing_attribute, n, caller) } result && result.to_s |