提交 5abff7cf 编写于 作者: Y Yves Senn

guides, move incomplete example to corresponding option. #21349

[ci skip]

This example is dependent on the `:end_at` option and has been removed
from `4-2-stable` (d167b811)
上级 ef8d09d9
......@@ -341,8 +341,6 @@ User.find_each(begin_at: 2000, batch_size: 5000) do |user|
end
```
Another example would be if you wanted multiple workers handling the same processing queue. You could have each worker handle 10000 records by setting the appropriate `:begin_at` option on each worker.
**`:end_at`**
Similar to the `:begin_at` option, `:end_at` allows you to configure the last ID of the sequence whenever the highest ID is not the one you need.
......@@ -356,6 +354,10 @@ User.find_each(begin_at: 2000, end_at: 10000, batch_size: 5000) do |user|
end
```
Another example would be if you wanted multiple workers handling the same
processing queue. You could have each worker handle 10000 records by setting the
appropriate `:begin_at` and `:end_at` options on each worker.
#### `find_in_batches`
The `find_in_batches` method is similar to `find_each`, since both retrieve batches of records. The difference is that `find_in_batches` yields _batches_ to the block as an array of models, instead of individually. The following example will yield to the supplied block an array of up to 1000 invoices at a time, with the final block containing any remaining invoices:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册