Skip to content

Instantly share code, notes, and snippets.

@ritxi
Created May 20, 2011 09:54
Show Gist options
  • Save ritxi/982654 to your computer and use it in GitHub Desktop.
Save ritxi/982654 to your computer and use it in GitHub Desktop.
counter cache dsl
cache_for :invitiations do |invitation|
invitation(:new) do |action|
action.increase(:create)
action.decrease(:update, :not => :to_pending?)
end
invitation(:accepted) do |action|
action.increase(:to_accepted?)
action.decrease(:update, :not => :to_accepted?)
end
invitation(:rejected) do |action|
action.increase(:update, :to_rejected?)
action.decrease(:not => :to_rejected?)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment