File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,11 @@ operations with examples.
145145 the save.*
146146
147147 *Pass* ``validate: false`` *option to bypass validations.*
148+
149+ *Pass* ``touch: false`` *option to ignore the updates to the updated_at
150+ field. If the document being save has not been previously persisted,
151+ this option is ignored and the created_at and updated_at fields will be
152+ updated with the current time.*
148153 -
149154 .. code-block:: ruby
150155
@@ -154,6 +159,7 @@ operations with examples.
154159 )
155160 person.save
156161 person.save(validate: false)
162+ person.save(touch: false)
157163
158164 person.first_name = "Christian Johan"
159165 person.save
Original file line number Diff line number Diff line change @@ -42,3 +42,18 @@ with a bang (!) raise an error:
4242
4343 Band.none.first!
4444 # => raise Mongoid::Errors::DocumentNotFound
45+
46+
47+ Added ``:touch`` option to ``#save``
48+ ------------------------------------
49+
50+ Support for the ``:touch`` option has been added to the ``#save`` and ``#save!``
51+ methods. When this option is false, the ``updated_at`` field on the saved
52+ document and all of it's embedded documents will not be updated with the
53+ current time. When this option is true or unset, the ``updated_at`` field will
54+ be updated with the current time.
55+
56+ If the document being saved is a new document (i.e. it has not yet been
57+ persisted to the database), then the ``:touch`` option will be ignored, and the
58+ ``updated_at`` (and ``created_at``) fields will be updated with the current
59+ time.
You can’t perform that action at this time.
0 commit comments