After recently upgrading to Rails 5.1, we noticed that certain model changes were no longer getting logged properly by
PaperTrail. After a bit of digging, this turned out to be due to a subtle difference in the way that Rails now tracks changes.
It’s a little contrived, but let’s say we have a model that becomes active once info is present, like this:
In Rails 5, we get something like:
However, after upgrading to Rails 5.1, we’ll get:
The state transition is now missing from the tracked changes.
NOTE: As of Rails 5.1, we’ll now see also see the following warning, but it doesn’t give us any indication of this small change in behavior.
DEPRECATION WARNING: The behavior of
changesinside of after callbacks will be changing in the next version of Rails. The new return value will reflect the behavior of calling the method after
savereturned (e.g. the opposite of what it returns now). To maintain the current behavior, use
Admittedly this is a small and isolated change, and this illustration is something of an anti-pattern, but this might just help clarify the new behavior for others seeing similar issues!