* integrate versioning into AR touch method
* add touch to list of :on events, deprecate touch_with_version
* integrate versioning into AR touch method
A destroy event can be handled either in a before-callback
or an after-callback. It's configurable.
However, we were not setting @in_after_callback accordingly.
I'm not aware of a specific bug caused by failing to set
this instance variable correctly, but if the instance variable
is a lie, it's easy to imagine such a bug now or in the future.
`before_save` doesn't accept `:on` as an argument, so this callback was actually running on all save events, not just on update.
https://github.com/rails/rails/issues/17622
Depending on what `reset_timestamp_attrs_for_update_if_needed` does, this might need to be backported to older versions.
I've submitted a PR to Rails to raise an exception when unexpected arguments are passed... unsure if an exception is the right way to go when there might be quite a few gems with this bug.
https://github.com/rails/rails/pull/30919
Problem
-------
`has_paper_trail` adds too many methods to the ActiveRecord model.
> If I'm counting correctly, installing the paper_trail gem adds 36 instance
> methods and 10 class methods to all of your active record models. Of those
> 46, 13 have a prefix, either "pt_" or "paper_trail_". I don't know what the
> best way to deal with this is. Ideally, we'd add far fewer methods to
> people's models. If we were able to add fewer methods to models, then I
> wouldn't mind prefixing all of them.
> https://github.com/airblade/paper_trail/issues/703
Solution
--------
Add only two methods to the AR model.
1. An instance method `#paper_trail`
2. A class method `.paper_trail`
The instance method would return a `RecordTrail` and the class method would
return a `ClassTrail`. Those names are totally up for debate.
Advantages
----------
- Plain ruby, easy to understand
- Adding new methods to e.g. the `RecordTrail` does not add any methods to
the AR model.
- Methods privacy is more strongly enforced.
- Enables isolated testing of e.g. `RecordTrail`; it can be constructed with a
mock AR instance.
Disadvantages
-------------
- Two new classes, though they are simple.