ActiveRecord not saving after updating attribute

后端 未结 3 785
青春惊慌失措
青春惊慌失措 2021-01-01 05:15

I\'m wondering if there is something at work here that I don\'t understand or if I\'ve run into a bug in ActiveRecord (4.1.1).

I have a database full of records with

3条回答
  •  时光说笑
    2021-01-01 05:42

    will_change!

    You can also use:

    test.json_data_will_change!   # Goes before the save.
    

    This will tell ActiveModel that the attribute, json_data, has changed (i.e. it's dirty ← there's a joke there somewhere) and will update the value properly on save.

    See Rails is not saving an attribute that is changed for some more details as well.

提交回复
热议问题