method
add_counter_cache_callbacks
v4.2.1 -
Show latest stable
- Class:
ActiveRecord::Associations::Builder::BelongsTo
add_counter_cache_callbacks(model, reflection)private
No documentation available.
# File activerecord/lib/active_record/associations/builder/belongs_to.rb, line 54
def self.add_counter_cache_callbacks(model, reflection)
cache_column = reflection.counter_cache_column
model.after_update lambda { |record|
record.belongs_to_counter_cache_after_update(reflection)
}
klass = reflection.class_name.safe_constantize
klass.attr_readonly cache_column if klass && klass.respond_to?(:attr_readonly)
end