3

Using Rails 3 I have a number of model containing serialized attributes. To perform the serialization I'm currently using 3 different techniques - the serialize method; activerecord store; and store configurable gem.

In all cases, when I save a model instance the serialized attribute is updated even if the content is unchanged. This was a surprising discovery particularly when using the store configurable gem as the readme states:

"StoreConfigurable is smart enough to let your parent object know when it changes. It is not dumb either. It will only trigger changes if the values you set are different, are new, or change the configs state."

Am I missing a trick here or if this is the expected behaviour is there a way to override it?

4

2 回答 2

3

根据此答案,始终保存序列化列的模型是预期的行为。

我还没有尝试过“存储可配置的 gem”,但听起来它应该足够聪明,可以检测到这一点。

于 2012-04-18T06:33:30.973 回答
1

我有类似的问题,所以在更新之前我正在重置所有值并让新值输入。

于 2012-04-12T13:37:51.410 回答