This project is archived and is in readonly mode.

#3464 ✓stale
Adam S

serialize_fields not recording changes

Reported by Adam S | November 5th, 2009 @ 06:22 PM

class Model < ActiveRecord::Base
  serialize :extra_data, Hash
end

m = Model.new
m.extra_data[:test] = 'test'
m.changed
=> []

I also find that models that use serialize fields will update those fields on every save of the model, whether the fields have changed or not. (I assume this is related to the serialize fields not recording changes)

Rails 2.3.4

Comments and changes to this ticket

  • Matt Jones

    Matt Jones November 7th, 2009 @ 06:07 PM

    This has come up a couple times: see tickets #2764 and #360.

  • Adam S

    Adam S November 9th, 2009 @ 12:38 AM

    Matt,
    Thanks for the links.

    I'm looking at the patch for #2764... It actually seems like the way to go about it. The data is serialized, so the only thing you can depend on is that the data should be the same when converted to yaml... if the data is the same in yaml, then the object hasn't changed. Simple.

    Really that is a great and obvious way to fix this issue.

    There are problems with converting various Object types to yaml, but that isn't rails' problem.

    Can we get that patch looked at again?

    I'm happy to rework it so that it applies against edge and Rails 2.3

  • Rohit Arondekar

    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>

Referenced by

Pages