Skip to content

Commit 15a8f10

Browse files
Update CHANGLOG
1 parent 52352bd commit 15a8f10

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
### 0.8.6 (Next)
1+
### 0.8.7 (Next)
22

33
* Your contribution here.
44

5+
### 0.8.6 (2024/08/07)
6+
7+
* [#257](https://github.com/mongoid/mongoid-history/pull/257): Add track_blank_changes option - [@BrianLMatthews](https://github.com/BrianLMatthews).
8+
59
### 0.8.5 (2021/09/18)
610

711
* [#250](https://github.com/mongoid/mongoid-history/pull/250): Migrate to Github actions - [@johnnyshields](https://github.com/johnnyshields).

README.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Post
7575
:version_field => :version, # adds "field :version, :type => Integer" to track current version, default is :version
7676
:track_create => true, # track document creation, default is true
7777
:track_update => true, # track document updates, default is true
78-
:track_destroy => true # track document destruction, default is true
78+
:track_destroy => true, # track document destruction, default is true
79+
:track_blank_changes => false # track changes from blank? to blank?, default is false
7980
end
8081

8182
class Comment
@@ -283,6 +284,32 @@ end
283284

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

287+
### Track all blank changes
288+
289+
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:
290+
291+
```ruby
292+
class Book
293+
include Mongoid::Document
294+
...
295+
field :summary
296+
track_history # Use default of false for track_blank_changes
297+
end
298+
299+
# summary change not tracked if summary hasn't been set (or has been set to something that responds true to blank?)
300+
Book.find(id).update_attributes(:summary => '')
301+
302+
class Chapter
303+
include Mongoid::Document
304+
...
305+
field :title
306+
track_history :track_blank_changes => true
307+
end
308+
309+
# title change tracked even if title hasn't been set
310+
Chapter.find(id).update_attributes(:title => '')
311+
```
312+
286313
### Retrieving the list of tracked static and dynamic fields
287314

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

605632
## Copyright
606633

607-
Copyright (c) 2011-2020 Aaron Qian and Contributors.
634+
Copyright (c) 2011-2024 Aaron Qian and Contributors.
608635

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

0 commit comments

Comments
 (0)