Skip to content
autoaffection edited this page Jun 12, 2020 · 2 revisions

When does flex_columns write JSON to the database?

Only when it absolutely has to. flex_columns will not even parse JSON in a column unless you try to read from one of its fields (or write to it), and it will not write back out JSON to the database (when you call save or save! on the model instance) unless you've changed at least one field in the flex column to a different value than it had previously. (This check is made using ==.)

If you want to force flex_columns to write data back to the database, call #touch! on the flex-column object, which will force it to parse the JSON in the database when you call #touch!, and ensure that the JSON will be written back to the database when you call save or save! on the model instance, even if you haven't actually changed any of its data.

Clone this wiki locally