Currently in Mongoid, there is a :touch option on the embedded_in association. This option defaults to false. Specifying touch: false (the default) in mongoid 8 and earlier has the following functionality:
- calling #touch on the child touches the parent
- updating the child does not update the updated_at of the parent
MONGOID-5142, this changed to, for touch: false:
- calling #touch on the child does not touch the parent (different than 8.0 default)
- updating the child does not update the updated_at of the parent (same)
for touch: true:
- calling #touch on the child touches the parent (same as 8.0 default)
- updating the child updates the updated_at of the parent (different)
MONGOID-5142, the default behavior has changed whether or not we keep the :touch default as true or false. I think we should take this opportunity to change the default of the :touch option to true, as per the use cases below.
If we decide to keep touch: false as the default, we should add to the release notes that the default behavior of touch has changed.
Note that the default for referenced associations would stay the same (false)
Currently in Mongoid, when an embedded document is saved, the parent is also saved. If an embedded document is touched, the parent therefore would also be touched. It is possible to specify touch:false on an embedded_in association but this has no effect. To provide diagnostics for this incorrect usage, Mongoid should prohibit specifying touch:false on an embedded_in association.
Additionally don't forget to update the docs here: https://docs.mongodb.com/mongoid/7.3/tutorials/mongoid-relations/index.html#touching
https://jira.mongodb.org/browse/MONGOID-5274 is filed as an improvement ticket to implement touch:false behavior for embedded associations.