method

inverse_updates_counter_cache?

Importance_1
v3.1.0 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::HasManyAssociation
inverse_updates_counter_cache?(reflection = reflection) private

This shit is nasty. We need to avoid the following situation:

* An associated record is deleted via record.destroy
* Hence the callbacks run, and they find a belongs_to on the record with a
  :counter_cache options which points back at our owner. So they update the
  counter cache.
* In which case, we must make sure to *not* update the counter cache, or else
  it will be decremented twice.

Hence this method.

Show source
Register or log in to add new notes.