Class: Counter

Inherits:
ApplicationRecord show all
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

Method Summary

Methods inherited from ApplicationRecord

sync_carrierwave_url