Home Rails Find_each,find_by_batch
Post
Cancel

Rails Find_each,find_by_batch

refer to:

find_each

用法很简单,就是跟  Model.where.each do ... 一样的。

find_by_batch:

循环的时候,里面是  一个model array.

Block.where('id < 30').find_in_batches(batch_size: 10) do |g| g.each {|b| puts b.id} end;

This post is licensed under CC BY 4.0 by the author.
Contents