Update multiple records simultaneously with ActiveRecord in Rails using one query?

后端 未结 3 480
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 14:44

Let\'s suppose I have a table called \'user_products\' and a corresponding model called UserProduct in my Rails application. I also have a field called \'is_temporary\' in my ta

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 14:49

    UserProduct.update_all({:is_temporary => false}, {:user_id => 12345})
    

提交回复
热议问题