Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

_was doesn't work correctly for serialized fields with nested elements

#3474

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.

Reported by Matt Jones · November 9th, 2009 @ 06:29 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 6th, 2010 @ 06:32 AM

  2. bingbing