diff --git a/README.md b/README.md index 2b1af5db..d4bf9782 100644 --- a/README.md +++ b/README.md @@ -135,17 +135,19 @@ When you declare `has_paper_trail` in your model, you get these methods: ```ruby class Widget < ActiveRecord::Base - has_paper_trail # you can pass various options here + has_paper_trail end -# Returns this widget's versions. You can customise the name of the association. +# Returns this widget's versions. You can customise the name of the +# association. widget.versions # Return the version this widget was reified from, or nil if it is live. # You can customise the name of the method. widget.version -# Returns true if this widget is the current, live one; or false if it is from a previous version. +# Returns true if this widget is the current, live one; or false if it is from +# a previous version. widget.live? # Returns who put the widget into its current state. @@ -160,7 +162,8 @@ widget.previous_version # Returns the widget (not a version) as it became next. widget.next_version -# Generates a version for a `touch` event (`widget.touch` does NOT generate a version) +# Generates a version for a `touch` event (`widget.touch` does NOT generate a +# version) widget.touch_with_version # Turn PaperTrail off for all widgets. @@ -169,9 +172,11 @@ Widget.paper_trail_off! # Turn PaperTrail on for all widgets. Widget.paper_trail_on! -# Check whether PaperTrail is enabled for all widgets. +# Is PaperTrail enabled for Widget, the class? Widget.paper_trail_enabled_for_model? -widget.paper_trail_enabled_for_model? # only available on instances of versioned models + +# Is PaperTrail enabled for widget, the instance? +widget.paper_trail_enabled_for_model? ``` And a `PaperTrail::Version` instance has these methods: @@ -282,32 +287,14 @@ usual. Here's a helpful table showing what PaperTrail stores: - - - - - - - - - - - - - - - - - - - - -
EventModel BeforeModel After
createnilwidget
updatewidgetwidget
destroywidgetnil
+| *Event* | *create* | *update* | *destroy* | +| -------------- | -------- | -------- | --------- | +| *Model Before* | nil | widget | widget | +| *Model After* | widget | widget | nil | 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 @@ -319,6 +306,10 @@ class Article < ActiveRecord::Base end ``` +`has_paper_trail` installs callbacks for these lifecycle events. If there are +other callbacks in your model, their order relative to those installed by +PaperTrail may matter, so be aware of any potential interactions. + You may also have the `PaperTrail::Version` model save a custom string in it's `event` field instead of the typical `create`, `update`, `destroy`. PaperTrail supplies a custom accessor method called `paper_trail_event`, which it will