title: Rails - Pagination gem showing all items
body: <p>I am using the pagination gem to paginate customer orders. I've had to display the orders using relationships through the database:</p>
  
  <pre><code>&lt;table class="order-items"&gt;
  &lt;th&gt;Date&lt;/th&gt;
  &lt;th&gt;Order No.&lt;/th&gt;
  &lt;th&gt;View Order&lt;/th&gt;
  &lt;% @customer.orders.each do |order| %&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;%= order.created_at.strftime("%d %b. %Y") %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= order.id %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Show',  "../orders/#{order.id}" %&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;% end %&gt;   
  &lt;/table&gt;
  
  &lt;p&gt;&lt;%= will_paginate @orders %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>And the code in my controller:</p>
  
  <pre><code>  @customer = Customer.find(params[:id])
    @order = @customer.orders
    @orders = @order.paginate page: params[:page], order: 'title',
    per_page: 5
  </code></pre>
  
  <p>I've created 6 orders for this customer to test it. The problem I'm having is that the pagination pages appear correctly at the bottom (2 pages), but all 6 orders are still displayed in the list, and both paginated pages still show all 6 orders. </p>
  
  <p>I've managed to get the pagination to work fine for all other pages, so I'm assuming it's because I've got the order.line_items.each construct in there - so that's why it displays all 6. I don't know how to fix this though! Any help would be much appreciated, thanks!</p>