Different each iteration

Hi,
I've read a few days ago that rails has a each method that allows you to
speficy the number of iteration. I think the default number was 1000.
What is the name of the method?

myList.each_with_something or myList.each_something

Greg

does u speak about it ? http://api.rubyonrails.org/classes/ActiveRecord/Batches/ClassMethods.html

Ivan Nastyukhin
dieinzige@me.com

Do you mean the "each_slice" method of enumerable?

http://ruby-doc.org/core/classes/Enumerable.html

Greg Ma wrote:

Hi,
I've read a few days ago that rails has a each method that allows you to
speficy the number of iteration. I think the default number was 1000.
What is the name of the method?

myList.each_with_something or myList.each_something

Greg

You can specify the batch_size as an option to a find_each method. Batch
methods should be used when your request retrieves large amounts of
data:

"When processing large numbers of records, it's often a good idea to do
so in batches to prevent memory ballooning."

Pale Horse wrote:

Greg Ma wrote:

Hi,
I've read a few days ago that rails has a each method that allows you to
speficy the number of iteration. I think the default number was 1000.
What is the name of the method?

myList.each_with_something or myList.each_something

Greg

You can specify the batch_size as an option to a find_each method. Batch
methods should be used when your request retrieves large amounts of
data:

"When processing large numbers of records, it's often a good idea to do
so in batches to prevent memory ballooning."

There's also in_groups_of.

Best,

Marnen Laibow-Koser wrote:

There's also in_groups_of.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org

I'd forgotten about that method. In addition, you can
each_slice(integer) to divide an array. Though, 'enumerator' is required
in your Active Record model. I would recommend this approach if you're
splitting arrays into columns or rows. Else, batch_size and in_groups_of
are useful for retrieving large data sets.