Skip to content

Instantly share code, notes, and snippets.

View Empact's full-sized avatar

Benjamin Woosley Empact

View GitHub Profile
@Empact
Empact / has_counter_cache_on.rb
Created June 14, 2011 10:22
has_counter_cache_on is a simple ActiveRecord extension which allows you to have multiple counters for a single association, counted when simple conditions are met
# has_counter_cache_on is a simple ActiveRecord extension
# which allows you to have multiple counters for a single
# association, counted when simple conditions are met
#
# The implementation is adapted from the current
# add_counter_cache_callbacks code in Rails.
#
# Example:
#
# class Submission < ActiveRecord::Base