Rails 3 + activerecord, the best way to "mass update" a single field for all the records that meet a condition -


in rails 3, using activerecord, there single-query way set :hidden field true records meet condition ... say, example, :condition => [ "phonenum = ?", some_phone_number ]

if single query cannot it, optimal approach?

use update_all optional second parameter condition:

model.update_all({ hidden: true }, { phonenum: some_phone_number}) 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -