mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Add documentation for on option.
This commit is contained in:
parent
b65ffe155d
commit
cbf894d6fa
2 changed files with 13 additions and 1 deletions
12
README.md
12
README.md
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue