method
update_counters
v3.2.13 -
Show latest stable
- Class:
ActiveRecord::Associations::BelongsToAssociation
update_counters(record)private
No documentation available.
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 27
def update_counters(record)
counter_cache_name = reflection.counter_cache_column
if counter_cache_name && owner.persisted? && different_target?(record)
if record
record.class.increment_counter(counter_cache_name, record.id)
end
if foreign_key_present?
klass.decrement_counter(counter_cache_name, target_id)
end
end
end