Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Counter Cache column options do not accept multiple columns #19

sickboy opened this Issue · 2 comments

2 participants


I would like to cache both, total views and unique views.

The following does not make that happen (for obvious reasons):
is_impressionable :counter_cache => { :column_name => :view_counter_cache }
is_impressionable :counter_cache => { :column_name => :view_counter_cache_unique, :unique => true }

Is there a way to achieve this regardless, or could it be added?

is_impressionable :counter_cache => [{:column_name => :counter_cache}, {:column_name => :counter_cache_unique, :unique => true}]


is_impressionable :counter_cache => {:counter_cache => {}, :counter_cache_unique => {:unique => true}}


This would definitely be useful. The first example seems a little cleaner. I could also see this accommodating other conditions other than "unique" by accepting a lambda (like rails before_filter does). We should keep the original syntax, but allow the user to pass an array as well. I think we will have to change counter_cache_options and update_counter_cache in this module:

You can take a stab at it if you want. I will merge the changes if you do a pull request and include tests. coryschires may be able to help if you have any questions. He added the counter cache code to impressionist


Thanks! I will give it a shot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.