I've been experimenting with dirty tracking for serialized
models; the problem I've run into is that will_change! and
was don't work with nested arrays/hashes.
Example:
# o.some_serialized_field starts with { 'a' => [1,2], 'b' => [3,4] }
o.some_serialized_field_will_change!
o['a'][0] = 5
o.some_serialized_field_was # => gives { 'a' => [5,2], 'b' => [3,4] }
The issue is that attribute_will_change! calls clone_attribute,
which only calls Object#clone. For now, I'm planning to work around
the issue by defining my own some_serialized_field_will_change!
method, but it'd be nice for it to work correctly.
Note that this isn't about partial updates (like #2764 Supporting partial updates for serialized columns) or
automatic change detection (like #3464 serialize_fields not recording changes or
#360 Dirty tracking on serialized columns is broken)
- this is a glitch in the manual "mark dirty" functionality.