aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/querying.rb
diff options
context:
space:
mode:
authorSina Siadat <siadat@gmail.com>2015-07-18 20:44:13 +0430
committerSina Siadat <siadat@gmail.com>2015-08-07 10:26:38 +0430
commit25cee1f0373aa3b1d893413a959375480e0ac684 (patch)
treeafb44866a3b5f9411b02f6c91aa9c572e5beeafe /activerecord/lib/active_record/querying.rb
parent4b91db5b125dd7bd735e7f42eb8e2c14c0e6757e (diff)
downloadrails-25cee1f0373aa3b1d893413a959375480e0ac684.tar.gz
rails-25cee1f0373aa3b1d893413a959375480e0ac684.tar.bz2
rails-25cee1f0373aa3b1d893413a959375480e0ac684.zip
Add ActiveRecord::Relation#in_batches
`in_batches` yields Relation objects if a block is given, otherwise it returns an instance of `BatchEnumerator`. The existing `find_each` and `find_in_batches` methods work with batches of records. The new API allows working with relation batches as well. Examples: Person.in_batches.each_record(&:party_all_night!) Person.in_batches.update_all(awesome: true) Person.in_batches.delete_all Person.in_batches.map do |relation| relation.delete_all sleep 10 # Throttles the delete queries end
Diffstat (limited to 'activerecord/lib/active_record/querying.rb')
-rw-r--r--activerecord/lib/active_record/querying.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb
index 4e597590e9..87a1988f2f 100644
--- a/activerecord/lib/active_record/querying.rb
+++ b/activerecord/lib/active_record/querying.rb
@@ -6,7 +6,7 @@ module ActiveRecord
delegate :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, to: :all
delegate :find_by, :find_by!, to: :all
delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, to: :all
- delegate :find_each, :find_in_batches, to: :all
+ delegate :find_each, :find_in_batches, :in_batches, to: :all
delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins, :or,
:where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly,
:having, :create_with, :uniq, :distinct, :references, :none, :unscope, to: :all