This is probably one of the things that all new users find out about Rails sooner or later. I just realized that rails is updating all fields with the serialize keyword, without checking if anything really changed inside. In a way that is the sensible thing to do for the generic framework.
But is there a way to override this behavior? If I can keep track of whether the values in a serialized fields have changed or not, is there a way to prevent it from being pushed in the update statement? I tried using “update_attributes” and limiting the hash to the fields of interest, but rails still updates all the serialized fields.
Suggestions?
Yes, that was bugging me too. This is what I did for Rails 2.3.14 (or lower):
Then in your controller use:
Or define it in your model if you do not expect any changes to the serialized field once created (but update_attribute(:serialized_field => “update me” still works!)