aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarc Rendl Ignacio <marcrendlignacio@gmail.com>2017-08-13 13:12:01 +0800
committerMarc Rendl Ignacio <marcrendlignacio@gmail.com>2017-08-13 13:15:46 +0800
commit7afde4bbd229f4055182b59aa34aa51f8c35f146 (patch)
tree52b6de134bd9b8d216c9952123eb056de4e5a239 /activerecord
parente3962308e7947f3d99c70c192e2d1356d3420e1e (diff)
downloadrails-7afde4bbd229f4055182b59aa34aa51f8c35f146.tar.gz
rails-7afde4bbd229f4055182b59aa34aa51f8c35f146.tar.bz2
rails-7afde4bbd229f4055182b59aa34aa51f8c35f146.zip
Completes ActiveRecord::Batches.find_each example [ci skip]
The previous paragraph mentions that you can hand off the same processing queue to multiple workers. This completes the following example below it.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/batches.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb
index 141ad176ea..fa19c679cf 100644
--- a/activerecord/lib/active_record/relation/batches.rb
+++ b/activerecord/lib/active_record/relation/batches.rb
@@ -47,7 +47,12 @@ module ActiveRecord
# handle from 10000 and beyond by setting the +:start+ and +:finish+
# option on each worker.
#
- # # Let's process from record 10_000 on.
+ # # In worker 1, let's process until 9999 records.
+ # Person.find_each(finish: 9_999) do |person|
+ # person.party_all_night!
+ # end
+ #
+ # # In worker 2, let's process from record 10_000 and onwards.
# Person.find_each(start: 10_000) do |person|
# person.party_all_night!
# end