title: ActiveRecord is not including a relation
body: <p>I have a query like this:</p>
  
  <pre><code>PrimaryModel.includes(:associated_models)
    .where(foo: true)
    .where('associated_models.bar &gt;= 0')
  </code></pre>
  
  <p>Typically, this would prompt ActiveRecord to join in associated_models, but instead I get this error:</p>
  
  <blockquote>
    <p>ActiveRecord::StatementInvalid Exception: PG::UndefinedTable: ERROR: 
    missing FROM-clause entry for table "associated_models"</p>
  </blockquote>
  
  <p>However, a query like this will properly join the tables:</p>
  
  <pre><code>PrimaryModel.includes(:associated_models)
    .where(foo: true)
    .where(associated_models: { baz: true })
  </code></pre>
  
  <p>Also, and perhaps most telling, this works:</p>
  
  <pre><code>PrimaryModel.includes(:associated_models)
    .where(foo: true)
    .where(associated_models: { baz: true })
    .where('associated_models.bar &gt;= 0')
  </code></pre>
  
  <p>In this last one, 'associated_models' gets joined by <code>.where(associated_models: { baz: true })</code>, allowing <code>.where('associated_models.bar &gt;= 0')</code> to work properly. Anyone else experience this? Figure out a solution?</p>