Skip to content

Commit

Permalink
Update README as per #497 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
batter committed Mar 14, 2015
1 parent 090f8d0 commit ee7eb24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/paper_trail/has_paper_trail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

6 comments on commit ee7eb24

@dinjas
Copy link

@dinjas dinjas commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this was for #479 ?

@batter
Copy link
Collaborator Author

@batter batter commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, it was for the right number, but I accidentally staged some changes I was playing around w/ for an for #479.

@batter
Copy link
Collaborator Author

@batter batter commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with 6b039a2, thanks!

@dinjas
Copy link

@dinjas dinjas commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, no worries. I tried using the pt_originator method this morning and when it didn't work in our project, I did some digging :)

@batter
Copy link
Collaborator Author

@batter batter commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it's still called originator, but thinking of namespacing it. Naming is hard!

@dinjas
Copy link

@dinjas dinjas commented on ee7eb24 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 haha it definitely is

Please sign in to comment.