Module: ActiveRecord::CounterCache::ClassMethods

Defined in:
lib/composite_primary_keys/counter_cache.rb

Instance Method Summary collapse

Instance Method Details

#update_counters(id, counters) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/composite_primary_keys/counter_cache.rb', line 4

def update_counters(id, counters)
  # CPK
  if self.composite?
    predicate = cpk_id_predicate(self.arel_table, primary_key, id)
    unscoped.where!(predicate).update_counters(counters)
  else
    unscoped.where!(primary_key => id).update_counters(counters)
  end
end