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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
does u speak about it ? http://api.rubyonrails.org/classes/ActiveRecord/Batches/ClassMethods.html Ivan Nastyukhin dieinzige-BUHhN+a2lJ4@public.gmane.org On Jun 16, 2010, at 12:19 PM, 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 > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 June 2010 09:19, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> myList.each_with_something or myList.each_somethingDo you mean the "each_slice" method of enumerable? http://ruby-doc.org/core/classes/Enumerable.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 > > GregYou 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." -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> > There''s also in_groups_of. > > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgI''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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.