1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Docs: Mention contr. callback more prominently

[Fixes #694]

[ci skip]
This commit is contained in:
Jared Beck 2016-01-20 12:04:52 -05:00
parent c200721005
commit b9f23d729f

View file

@ -57,7 +57,7 @@ has been destroyed.
1. Add PaperTrail to your `Gemfile`.
`gem 'paper_trail', '~> 4.0.0'`
`gem 'paper_trail'`
1. Add a `versions` table to your database.
@ -68,19 +68,26 @@ has been destroyed.
1. Add `has_paper_trail` to the models you want to track.
```ruby
class Widget < ActiveRecord::Base
has_paper_trail
end
```
1. If your controllers have a `current_user` method, you can easily [track who
is responsible for changes](#finding-out-who-was-responsible-for-a-change)
by adding a controller callback.
```ruby
class ApplicationController
before_filter :set_paper_trail_whodunnit
end
```
## Basic Usage
Add `has_paper_trail` to your model to record every `create`, `update`,
and `destroy`.
```ruby
class Widget < ActiveRecord::Base
has_paper_trail
end
```
This gives you a `versions` method which returns the "paper trail" of changes to
your model.
Your models now have a `versions` method which returns the "paper trail" of
changes to your model.
```ruby
widget = Widget.find 42