From cbf894d6faff52ed00fb2968c24e6023e412aa99 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 22 Aug 2011 10:24:04 +0200 Subject: [PATCH] Add documentation for on option. --- README.md | 12 +++++++++++- lib/paper_trail/has_paper_trail.rb | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b14918c4..5fe5b0c7 100644 --- a/README.md +++ b/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: diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 3bbd37ba..610d1286 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -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