I have a simple user model with a name and settings. After every save of user AREL is performing an update to the settings column. For example:
user = User.find_by_name('kevin')
user.save
(0.3ms) UPDATE "users" SET "updated_at" = '2011-10-20 19:58:06.363541', "settings" = '--- {}' WHERE "users"."id" = 1
None of the other fields are updated when calling save. Is this expected behavior? Why is it performing the update? Can it be turned off to not change if the serialized contents haven’t changed? I’ve uploaded the sample project used to create a minimum case:
This is expected behavior. It is very difficult to detect changes within a serialized attribute, so they are updated on every save.
Consider the following (ruby 1.8.7) irb session: