Follow Along as I Stumble on the Path to Learning RoR

Mass Update / Initialize Database Field

I have a field that I need to mass update and I was looking for an efficient way to update them.  I found it with “update_all”.  By doing:

Model.update_all :field=>value

It will update all of the records to the value you want.  If you want to do it for only certain records, you can use a where clause like so:

Model.where(“foo = ?”, “bar”).update_all :field=>value


Comments are closed.