Class: Counter
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Counter
- Includes:
- IdentityCache
- Defined in:
- app/models/counter.rb
Overview
Define virtual attribute
Usage:
class User < ApplicationRecord
define_counter_cache :friends_count do |_|
_.friends.count
end
end
User instance will have `friends_count` method it will be updated on `after_save` callback
Defined Under Namespace
Modules: CounterCache