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

php - How to build a web site which gives a sub-domain dynamically to every registered user? -

Delphi Wmi Query on a Remote Machine -