This project is archived and is in readonly mode.
_was doesn't work correctly for serialized fields with nested elements
Reported by Matt Jones | November 9th, 2009 @ 06:29 PM
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) or automatic change detection (like #3464 or #360) - this is a glitch in the manual "mark dirty" functionality.
Comments and changes to this ticket
-
Rohit Arondekar October 6th, 2010 @ 06:32 AM
- 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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Tags
Referenced by
- 4614 Cloned object mimic changed_attributes from creator after being clonde Also note that the use of dup to create the new changed_a...