I have a number of tables in which I set all fields to zero, except for a few select ones (including foreign keys and some time values), on a weekly basis. At the moment, I'm using the update_all(field: value, ...) command, which works just fine. The only issue is that I have to list out each field I want to clear, and I often forget to add the field here when I change the table, which leads to errors.
Is there some way to have rails clear all fields in a table except for a specified few?
Thanks!
In Rails every model has method
columnswhich returns list of columns. You may do something like this for every model: