Skip to content

Commit

Permalink
Merge pull request #1247 from tlynam/bugfix/ignore-when-using-proc
Browse files Browse the repository at this point in the history
Updates Readme sections for `only` and `ignore`
  • Loading branch information
tlynam committed Aug 9, 2020
2 parents fa8b1b2 + fe591c1 commit cccbe5a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,14 @@ a.versions.length # 2
a.paper_trail.previous_version.title # 'My Title'
```

The `:ignore` option can also accept `Hash` arguments that we are considering deprecating.

```ruby
class Article < ActiveRecord::Base
has_paper_trail ignore: [:title, { color: proc { |obj| obj.color == "Yellow" } }]
end
```

#### Only

Or, you can specify a list of the `only` attributes you care about:
Expand All @@ -450,11 +458,11 @@ a.versions.length # 2
a.paper_trail.previous_version.content # nil
```

The `:ignore` and `:only` options can also accept `Hash` arguments.
The `:only` option can also accept `Hash` arguments that we are considering deprecating.

```ruby
class Article < ActiveRecord::Base
has_paper_trail only: { title: Proc.new { |obj| !obj.title.blank? } }
has_paper_trail only: [{ title: Proc.new { |obj| !obj.title.blank? } }]
end
```

Expand Down

0 comments on commit cccbe5a

Please sign in to comment.