Update a column, all rows

前端 未结 4 1739

I added a new column to my table but I forgot to add the :default option. Now I want to populate that column on every single row.

Is there a way to do with using the con

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 02:00

    Try this:

    Foo.update_all(some_column: "bar")
    

    This will generate SQL query to database:

    UPDATE "foos" SET "some_column" = "bar"; 
    

提交回复
热议问题