In many parts of my Rails 6 app I have belongs_to
associations with touch: true
which means that the updated_at
value of the parent object gets updated when the child is updated.
The problem is that I am using the Paper Trail gem to track changes in the data, but I don't want version records for the objects when they simply have been "touched" in this way.
I've tried using the ignore
option on the updated_at
field like this:
has_paper_trail ignore: [:updated_at]
which causes no version to be created when I do this
my_object.update(updated_at: Time.current)
but it still creates a version when I do this
my_object.touch
Paper Trail treats a "touch" operation separately from other updates. It can trigger versioning on any or all of these operations: create, destroy, update, touch.
Use the on
option in order to specify a subset of operation that trigger versions that excludes 'touch'. Like this
has_paper_trail on: [:create, :destroy, :update]
In the docs this is descibed in section 2.a. (Choosing Lifecycle Events To Monitor)