I use the json field to store some additional parameters in one of my models.
It works great, except for the fact that it does not detect the changes that I make when accessing data using square brackets:
2.1.1 :002 > p = Payments.last => {...} 2.1.1 :003 > p.params.keys => ["receipt_data"] 2.1.1 :004 > p.params['verification_data'] = 'test' => "test" 2.1.1 :005 > p.params.keys => ["receipt_data", "verification_data"] 2.1.1 :006 > p.params_changed? => false 2.1.1 :007 > p.save (0.2ms) BEGIN (0.2ms) COMMIT => true 2.1.1 :008 > Payment.last.params.keys Payment Load (0.5ms) SELECT "payments".* FROM "payments" ORDER BY "payments"."id" DESC LIMIT 1 => ["receipt_data"]
How to make it save changes?
source share