lib/mongoid/association/referenced/counter_cache.rb
# Reset the given counter using the .count() query from the
# db. This method is useful 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 ] counters One or more counter caches to reset
Reset the given counter using the .count() query from the
db. This method is useful in case that a counter got
corrupted, or a new counter was added to the collection.
Reset the given counter using the . count () query from the db . This method is useful in case that a counter got corrupted or a new counter was added to the collection .
def reset_counters(*counters)
          self.class.with(persistence_context) do |_class|
            _class.reset_counters(self, *counters)
          end
        end
def reset_counters ( * counters ) self . class . with ( persistence_context ) do | _class | _class . reset_counters ( self , * counters ) end end
Reset the given counter using the .count() query from the
db.
Reset the given counter using the . count () query from the db .
counters
<not_specific>
<not_specific>
counters One or more counter caches to reset
counters One or more counter caches to reset
example
Reset the given counter cache post.reset_counters(:comments)
Reset the given counter cache post . reset_counters ( : comments )