title: undefined method `find_each' for []:Array
body: <p>I have code something like this. </p>
  
  <pre><code>@deliveries = User.find_uniq_deliveries(...)
  .
  .
  .
  (many conditions added using 'named_scope' )
  @deliveries.sort do |a,b|
  .
  .
  end
  </code></pre>
  
  <p>The main problem is this is fetching lots of results and giving Oracle  exception that more than 1000 elements are not allowed in 'in' statement. 
  So I tried using find_each to fetch in batches </p>
  
  <pre><code>deliveries_list = [] 
  @deliveries.find_each(:batch_size=999) do |delivery|
      deliveries_list.push(delivery)
  end
  @deliveries = deliveries_list
  </code></pre>
  
  <p>But this gives the exception </p>
  
  <blockquote>
    <p>undefined method `find_each' for []:Array</p>
  </blockquote>
  
  <p>As you can see am quite new to rails ( coming from java) and rails totally don't make sense to me. What can I do to prevent Oracle SQL error but fetch data </p>
  
  <p>EDIT : </p>
  
  <pre><code>  def find_uniq_deliveries(category,date,view)
      dels = []
      sent_deliveries.send("for_#{category}s").send("with_#{category}_status", view).for_date_range(date).collect(&amp;:workflow_item).uniq.each do |m|
        dels &lt;&lt; m.deliveries.first unless m.deliveries.empty?
      end
      dels.compact
    end
  </code></pre>