Add documentation for on option.

This commit is contained in:
Andy Stewart 2011-08-22 10:24:04 +02:00
parent b65ffe155d
commit cbf894d6fa
2 changed files with 13 additions and 1 deletions

View File

@ -7,7 +7,7 @@ There's an excellent [Railscast on implementing Undo with Paper Trail](http://ra
## Features
* Stores every create, update and destroy.
* Stores every create, update and destroy (or only the lifecycle events you specify).
* Does not store updates which don't change anything.
* Allows you to specify attributes (by inclusion or exclusion) which must change for a Version to be stored.
* Allows you to get at every version, including the original, even once destroyed.
@ -169,6 +169,16 @@ Here's a helpful table showing what PaperTrail stores:
PaperTrail stores the values in the Model Before column. Most other auditing/versioning plugins store the After column.
## Choosing Lifecycle Events To Monitor
You can choose which events to track with the `on` option. For example, to ignore `create` events:
class Article < ActiveRecord::Base
has_paper_trail :on => [:update, :destroy]
end
## Choosing Attributes To Monitor
You can ignore changes to certain attributes like this:

View File

@ -11,6 +11,8 @@ module PaperTrail
# the model is available in the `versions` association.
#
# Options:
# :on the events to track (optional; defaults to all of them). Set to an array of
# `:create`, `:update`, `:destroy` as desired.
# :class_name the name of a custom Version class. This class should inherit from Version.
# :ignore an array of attributes for which a new `Version` will not be created if only they change.
# :only inverse of `ignore` - a new `Version` will be created only for these attributes if supplied