title: Rails ActiveRecord ORDER BY not respected in nested includes
body: <p>I'm encountering a strange issue. I tried to google about it but I may not be using the right wording (I am quite new at RoR).</p>
  
  <p>I'm using some nested eager loading through a scope of one of my models. So I have something like this:</p>
  
  <pre><code>scope :includes_all, lambda {includes(
    :buggy_relation,
    :another_relation,
    an_attribute: [:first_attribute, :second_attribute])}
  </code></pre>
  
  <p>Where :buggy_relation is declared as something like this in the same model:</p>
  
  <pre><code>has_many :buggy_relation, -&gt; {order(:order_index)}, class_name: 'SomeClass'
  </code></pre>
  
  <p>So, the point is, as long as I do not have <code>an_attribute</code> in my <code>includes()</code> statement, the SQL request looks correct and I can see the ORDER BY statement done on my SomeClass.order_index. But, as soon as I add the nested loading with <code>an_attribute: [:first_attribute, :second_attribute]</code>, the order of the <code>:buggy_relation</code> is not taken into account anymore. The buggy relation is obviously loaded, but nowhere is the corresponding ORDER BY stated which leads to the order not to be respected.</p>
  
  <p>An example of the misbehaviour would be having a blog post with comments:</p>
  
  <pre><code>#EXPECTED
  post -&gt; comment 1
       -&gt; comment 2
       -&gt; comment 3
  
  #OBTAINED
  post -&gt; comment 2
       -&gt; comment 3
       -&gt; comment 1
  </code></pre>
  
  <p>If you have any hint about this...</p>