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
In Rails 5, there's a new handy method ActiveRecord::Relation#in_batches to solve this problem:
ActiveRecord::Relation#in_batches
Foo.in_batches.update_all(bar: 'baz')
Check documentation for details.