explain how to add unique options to counter_cache and others...

This commit is contained in:
Antonio C Nalesso Moreira 2013-07-06 03:29:35 +01:00
parent 581232c337
commit 45429ca185
1 changed files with 22 additions and 3 deletions

View File

@ -143,8 +143,16 @@ like specific a different column name, you can:</b>
If you'd like to include only unique impressions in your count: If you'd like to include only unique impressions in your count:
# default will be filtered by ip_address
is_impressionable :counter_cache => { :column_name => :my_column_name, :unique => true } is_impressionable :counter_cache => { :column_name => :my_column_name, :unique => true }
If you'd like to specify what sort of unique impression you'd like to save? Fear not,
Any option you pass to unique, impressionist_count will use it as its filter to update_counters based on that unique option.
# options are any column in the impressions' table.
is_impressionable :counter_cache => { :column_name => :my_column_name, :unique => :request_hash }
is_impressionable :counter_cache => { :column_name => :my_column_name, :unique => :all }
Adding column to model Adding column to model
---------------------- ----------------------
@ -177,7 +185,7 @@ Are you using Mongoid?
Execute this command on your terminal/console: Execute this command on your terminal/console:
rails g impressionist --orm mongoid rails g impressionist --orm mongoid
This command create a file `impression.rb` on `config/initializer` folder. Add `config.orm = :mongoid` to this file: This command create a file `impression.rb` on `config/initializer` folder. Add `config.orm = :mongoid` to this file:
# Use this hook to configure impressionist parameters # Use this hook to configure impressionist parameters
@ -186,7 +194,7 @@ This command create a file `impression.rb` on `config/initializer` folder. Add `
# config.orm = :active_record # config.orm = :active_record
config.orm = :mongoid config.orm = :mongoid
end end
Contributing to impressionist Contributing to impressionist
----------------------------- -----------------------------
@ -204,10 +212,21 @@ Contributing to impressionist
* All testing is done inside a small Rails app (test_app). You will find specs * All testing is done inside a small Rails app (test_app). You will find specs
within this app. within this app.
Want to run the tests? Ok mummy
-------------------------------
* bundle install
* rails g impressionist
* rake db:migrate && rake db:test:prepare
* Run rake or rspec spec inside test_app dir
* nothing else.
* :wq
Contributors Contributors
------------ ------------
* [johnmcaliley](https://github.com/johnmcaliley) * [johnmcaliley](https://github.com/johnmcaliley)
* [coryschires](https://github.com/coryschires) * [coryschires](https://github.com/coryschires)
* [georgmittendorfer](https://github.com/georgmittendorfer) * [georgmittendorfer](https://github.com/georgmittendorfer)
* [Antonio C Nalesso](https://github.com/nbit001)
Copyright (c) 2011 John McAliley. See LICENSE.txt for further details. Copyright (c) 2011 John McAliley. See LICENSE.txt for further details.