From ee7eb24df3f14a651157d29a2a61fcea6a1573da Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Sat, 14 Mar 2015 18:35:04 -0400 Subject: [PATCH] Update README as per #497 [ci skip] --- CHANGELOG.md | 2 ++ README.md | 6 +++--- lib/paper_trail/has_paper_trail.rb | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e48fa807..4e821af0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ If you depend on the `RSpec` or `Cucumber` helpers, you will need to [manually l - [#484](https://github.com/airblade/paper_trail/pull/484) - Support for [PostgreSQL's JSONB Type](http://www.postgresql.org/docs/9.4/static/datatype-json.html) for storing `object` and `object_changes`. + - [#479](https://github.com/airblade/paper_trail/issues/479) - Renamed `PaperTrail::Model::InstanceMethods#orriginator` to + `pt_originator` (or `paper_trail_originator`) - [#458](https://github.com/airblade/paper_trail/pull/458) - For `create` events, metadata pointing at attributes should attempt to grab the current value instead of looking at the value prior to the change (which would always be `nil`) - [#440](https://github.com/airblade/paper_trail/pull/440) - `versions` association should clear/reload after a transaction rollback. diff --git a/README.md b/README.md index 0e2ebc3cd..acb4bd54f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ widget.version widget.live? # Returns who put the widget into its current state. -widget.originator +widget.pt_originator # Returns the widget (not a version) as it looked at the given timestamp. widget.version_at(timestamp) @@ -152,7 +152,7 @@ version.reify(options = {}) version.reify(dup: true) # Returns who put the item into the state stored in this version. -version.originator +version.pt_originator # Returns who changed the item from the state it had in this version. version.terminator @@ -655,7 +655,7 @@ If the parent and child are updated in one go, PaperTrail can use the aforementi >> t.location.latitude # 12.345, instead of 54.321 ``` -By default, PaperTrail excludes an associated record from the reified parent model if the associated record exists in the live model but did not exist as at the time the version was created. This is usually what you want if you just want to look at the reified version. But if you want to persist it, it would be better to pass in option `:mark_for_destruction => true` so that the associated record is included and marked for destruction. +By default, PaperTrail excludes an associated record from the reified parent model if the associated record exists in the live model but did not exist as at the time the version was created. This is usually what you want if you just want to look at the reified version. But if you want to persist it, it would be better to pass in option `:mark_for_destruction => true` so that the associated record is included and marked for destruction. Note that `mark_for_destruction` only has [an effect on associations marked with `autosave: true`](http://api.rubyonrails.org/classes/ActiveRecord/AutosaveAssociation.html#method-i-mark_for_destruction). ```ruby class Widget < ActiveRecord::Base diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 2ff0eaa1b..de69bf09c 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -182,8 +182,14 @@ def live? # Returns who put the object into its current state. def originator + warn "DEPRECATED: use `pt_originator` instead of `originator`. Support for `originator` will be removed in PaperTrail 4.0" + pt_originator + end + + def pt_originator (source_version || send(self.class.versions_association_name).last).try(:whodunnit) end + alias_method :paper_trail_originator, :pt_originator # Invoked after rollbacks to ensure versions records are not created # for changes that never actually took place