From 7e7a349c42bcc149b2cec5f31c664ad8f652926b Mon Sep 17 00:00:00 2001 From: Jared Beck Date: Mon, 10 Aug 2015 00:24:22 -0400 Subject: [PATCH] Docs: Update example of Diffing Versions [ci skip] --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8fe9d54a..173e9ab2 100644 --- a/README.md +++ b/README.md @@ -662,15 +662,26 @@ attributes PaperTrail is ignoring) in each `update` version. You can use the ```ruby widget = Widget.create :name => 'Bob' -widget.versions.last.changeset # {'name' => [nil, 'Bob']} +widget.versions.last.changeset +# { +# "name"=>[nil, "Bob"], +# "created_at"=>[nil, 2015-08-10 04:10:40 UTC], +# "updated_at"=>[nil, 2015-08-10 04:10:40 UTC], +# "id"=>[nil, 1] +# } widget.update_attributes :name => 'Robert' -widget.versions.last.changeset # {'name' => ['Bob', 'Robert']} +widget.versions.last.changeset +# { +# "name"=>["Bob", "Robert"], +# "updated_at"=>[2015-08-10 04:13:19 UTC, 2015-08-10 04:13:19 UTC] +# } widget.destroy -widget.versions.last.changeset # {} +widget.versions.last.changeset +# {} ``` -Note PaperTrail only stores the changes for creation and updates; it doesn't -store anything when an object is destroyed. +The `object_changes` are only stored for creation and updates, not when an +object is destroyed. Please be aware that PaperTrail doesn't use diffs internally. When I designed PaperTrail I wanted simplicity and robustness so I decided to make each version @@ -1072,7 +1083,7 @@ end ### Protected Attributes and Metadata -If you are using rails 3 or the [protected_attributes][17] gem you must declare +If you are using rails 3 or the [protected_attributes][17] gem you must declare your metadata columns to be `attr_accessible`. ```ruby