method
update_counters
v5.1.7 -
Show latest stable
- Class:
ActiveRecord::Associations::BelongsToAssociation
update_counters(by)private
No documentation available.
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 47
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
klass.update_counters(target_id, reflection.counter_cache_column => by, touch: reflection.options[:touch])
end
end
end