How can I run updates in batches in Rails 3/4?

后端 未结 6 1070
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 01:09

I need to mass-update many thousands of records, and I would like to process the updates in batches. First, I tried:

Foo.where(bar: \'bar\').find_in_batches.upda         


        
6条回答
  •  伪装坚强ぢ
    2021-02-05 02:05

    I've written a small method to invoke update_all in batches:

    https://gist.github.com/VarunNatraaj/420c638d544be59eef85

    Hope it is useful! :)

提交回复
热议问题