In rails 3, using activerecord, is there a single-query way to set the :hidden field to TRUE for all records that meet a condition ... say, for example, :condition => [ "phonenum = ?", some_phone_number ]
If a single query cannot do it, what IS the optimal approach?
Use update_all with the optional second parameter for the condition:
Model.update_all({ hidden: true }, { phonenum: some_phone_number})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With