Skip to content

Commit e9f603a

Browse files
MONGOID-5504 Clear changes after :touch (#5534)
1 parent e462bbf commit e9f603a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

source/release-notes/mongoid-9.0.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ The complete list of releases is available `on GitHub
1717
please consult GitHub releases for detailed release notes and JIRA for
1818
the complete list of issues fixed in each release, including bug fixes.
1919

20+
``touch`` method now clears changed state
21+
-----------------------------------------
22+
23+
In Mongoid 8.x and older ``touch`` method leaves models in the changed state:
24+
25+
.. code-block:: ruby
26+
27+
# Mongoid 8.x behaviour
28+
band = Band.create!
29+
band.touch
30+
band.changed? # => true
31+
band.changes # => {"updated_at"=>[2023-01-30 13:12:57.477191135 UTC, 2023-01-30 13:13:11.482975646 UTC]}
32+
33+
Starting from 9.0 Mongoid now correctly clears changed state after using ``touch``
34+
method.
35+
36+
.. code-block:: ruby
37+
38+
# Mongoid 9.0 behaviour
39+
band = Band.create!
40+
band.touch
41+
band.changed? # => false
42+
band.changes # => {}
43+
2044
Sandbox Mode for Rails Console
2145
------------------------------
2246

0 commit comments

Comments
 (0)