title: Specifying conditions in Rails Query with includes not working
body: <p>I am really stuck in something quite simple. I am unable to specify conditions in my active record query with includes.
  Following is my code that states my problem.</p>
  
  <pre><code>2.2.1 :072 &gt; visitor = Visitor.includes(:campaign).first
  2.2.1 :073 &gt; visitor.campaign.merchant_id
   =&gt; 123456
  </code></pre>
  
  <p>Above mentioned case is working well.
  Now when I try the following it fails.</p>
  
  <pre><code>2.2.1 :076 &gt; visitor = Visitor.includes(:campaign).where("campaign.merchant_id = 123456").references(:campaign).first
  ERROR -- : Mysql2::Error: Unknown column 'campaign.merchant_id' in 'where clause'
  </code></pre>
  
  <p>Any help is highly appreciated. Just for your info.
  Campaign has many visitors
  Visitor belongs to a campaign
  Campaign has an attribute merchant_id which i am using to specify a condition.</p>