module Mongoid::Relations::CounterCache
Public Instance Methods
reset_counters(*counters)
click to toggle source
Reset the given counter using the .count() query from the db. This method is usuful in case that a counter got corrupted, or a new counter was added to the collection.
@example Reset the given counter cache
post.reset_counters(:comments)
@param [ Symbol
, Array ] One
or more counter caches to reset
@since 4.0.0
# File lib/mongoid/relations/counter_cache.rb, line 17 def reset_counters(*counters) self.class.with(persistence_context) do |_class| _class.reset_counters(self, *counters) end end