title: rails eager loading not working with each on include association
body: <p>I have the following:</p>
  
  <p>order.rb</p>
  
  <pre><code>  belongs_to :user
    belongs_to :property
    has_many :order_lines, :dependent =&gt; :destroy
  </code></pre>
  
  <p>order_line.rb</p>
  
  <pre><code>  belongs_to :order
    belongs_to :service
    belongs_to :status, :class_name =&gt; "SettingsOption"
  </code></pre>
  
  <p>orders_controller.rb</p>
  
  <pre><code>  def index
      @orders = Order.active_w_property.find_all_by_user_id(current_user.id,
          :include =&gt; {:order_lines =&gt; [:service, :status]})
    end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>...
  &lt;%= render :partial =&gt; 'order', :collection =&gt; @orders %&gt;
  ...
  </code></pre>
  
  <p>_order.html.erb</p>
  
  <pre><code>...
  &lt;% order.order_lines.each do |line| %&gt;
    &lt;% total = total + line.price %&gt;
    &lt;tr&gt;
      &lt;td&gt;
        &lt;%= line.service.option.nil? ?
              t(line.service.name) :
              [t(line.service.name), t(line.service.option)].join(" ") %&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;%= t(line.description) %&gt;&lt;/td&gt;
      &lt;td class="align-right"&gt;&lt;%= currencify_price(line.price) %&gt;&lt;/td&gt;
      &lt;td class="align-center"&gt;&lt;%= t(line.status.value) %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  ...
  </code></pre>
  
  <p>log for index.html.erb</p>
  
  <pre><code>  ←[4;36;1mOrder Load (2.0ms)←[0m   ←[0;1mSELECT ""very long query""
    ←[4;35;1mOrderLine Load (1.0ms)←[0m   ←[0mSELECT `order_lines`.* FROM `order_lines` WHERE (`order_lines`.order_id IN (10134,1
    ←[4;36;1mOrderLine Columns (5.0ms)←[0m   ←[0;1mSHOW FIELDS FROM `order_lines`←[0m
    ←[4;35;1mService Columns (14.0ms)←[0m   ←[0mSHOW FIELDS FROM `services`←[0m
    ←[4;36;1mService Load (3.0ms)←[0m   ←[0;1mSELECT * FROM `services` WHERE (`services`.`id` IN (6,7,8,9,1,2,3,4,10,5)) ←[0m
    ←[4;35;1mSettingsOption Columns (4.0ms)←[0m   ←[0mSHOW FIELDS FROM `settings_options`←[0m
    ←[4;36;1mSettingsOption Load (3.0ms)←[0m   ←[0;1mSELECT * FROM `settings_options` WHERE (`settings_options`.`id` = 167) ←[0m
  Rendering template within layouts/application
  Rendering myimmonatie/orders/index
  </code></pre>
  
  <p>log for _order.html.erb</p>
  
  <pre><code>Rendered myimmonatie/orders/_order (8.0ms)
    ←[4;36;1mOrderLine Load (0.0ms)←[0m   ←[0;1mSELECT * FROM `order_lines` WHERE (`order_lines`.order_id = 10112) ←[0m
    ←[4;35;1mCACHE (0.0ms)←[0m   ←[0mSELECT * FROM `services` WHERE (`services`.`id` = 1) ←[0m
    ←[4;36;1mCACHE (0.0ms)←[0m   ←[0;1mSELECT * FROM `settings_options` WHERE (`settings_options`.`id` = 167) ←[0m
    ←[4;35;1mCACHE (0.0ms)←[0m   ←[0mSELECT * FROM `services` WHERE (`services`.`id` = 5) ←[0m
    ←[4;36;1mCACHE (0.0ms)←[0m   ←[0;1mSELECT * FROM `settings_options` WHERE (`settings_options`.`id` = 167) ←[0m
    ←[4;35;1mCACHE (0.0ms)←[0m   ←[0mSELECT * FROM `services` WHERE (`services`.`id` = 3) ←[0m
    ←[4;36;1mCACHE (0.0ms)←[0m   ←[0;1mSELECT * FROM `settings_options` WHERE (`settings_options`.`id` = 167) ←[0m
    ←[4;35;1mCACHE (0.0ms)←[0m   ←[0mSELECT * FROM `services` WHERE (`services`.`id` = 2) ←[0m
    ←[4;36;1mCACHE (0.0ms)←[0m   ←[0;1mSELECT * FROM `settings_options` WHERE (`settings_options`.`id` = 167) ←[0m
  </code></pre>
  
  <p>For the controller index method all the included tables are loaded as expected. But for each order_line in the partial the order_lines are loaded again, though they were loaded before. Also the services are queried each time (though from cache). How can I let everything just be rendered without new querying?</p>
  
  <p><strong>UPDATE</strong>: using rails 2.3.11</p>