Skip to content

Commit

Permalink
Update CHANGLOG
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianLMatthews committed Aug 6, 2024
1 parent 52352bd commit 15a8f10
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
### 0.8.6 (Next)
### 0.8.7 (Next)

* Your contribution here.

### 0.8.6 (2024/08/07)

* [#257](https://github.com/mongoid/mongoid-history/pull/257): Add track_blank_changes option - [@BrianLMatthews](https://github.com/BrianLMatthews).

### 0.8.5 (2021/09/18)

* [#250](https://github.com/mongoid/mongoid-history/pull/250): Migrate to Github actions - [@johnnyshields](https://github.com/johnnyshields).
Expand Down
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Post
:version_field => :version, # adds "field :version, :type => Integer" to track current version, default is :version
:track_create => true, # track document creation, default is true
:track_update => true, # track document updates, default is true
:track_destroy => true # track document destruction, default is true
:track_destroy => true, # track document destruction, default is true
:track_blank_changes => false # track changes from blank? to blank?, default is false
end

class Comment
Expand Down Expand Up @@ -283,6 +284,32 @@ end

It will now track only `_id` (Mandatory), `title` and `content` attributes for `pages` relation.

### Track all blank changes

Normally changes where both the original and modified values respond with `true` to `blank?` (for example `nil` to `false`) aren't tracked. However, there may be cases where it's important to track such changes, for example when a field isn't present (so appears to be `nil`) then is set to `false`. To track such changes, set the `track_blank_changes` option to `true` (it defaults to `false`) when turning on history tracking:

```ruby
class Book
include Mongoid::Document
...
field :summary
track_history # Use default of false for track_blank_changes
end

# summary change not tracked if summary hasn't been set (or has been set to something that responds true to blank?)
Book.find(id).update_attributes(:summary => '')

class Chapter
include Mongoid::Document
...
field :title
track_history :track_blank_changes => true
end

# title change tracked even if title hasn't been set
Chapter.find(id).update_attributes(:title => '')
```

### Retrieving the list of tracked static and dynamic fields

```ruby
Expand Down Expand Up @@ -604,6 +631,6 @@ You're encouraged to contribute to Mongoid History. See [CONTRIBUTING.md](CONTRI

## Copyright

Copyright (c) 2011-2020 Aaron Qian and Contributors.
Copyright (c) 2011-2024 Aaron Qian and Contributors.

MIT License. See [LICENSE.txt](LICENSE.txt) for further details.

0 comments on commit 15a8f10

Please sign in to comment.