title: How to select 2 or more models back in a where clause
body: <p>In SQL you can have <code>SELECT x,y FROM ...</code> </p>
  
  <p>but if I use <code>where</code>, the sql generated will only select from the models which it is acting upon.</p>
  
  <p>So for example: </p>
  
  <pre><code>user has_many :posts
  post belongs_to :user
  </code></pre>
  
  <p><code>Post.includes(:users).where('created_at &lt; ?' 1.day.ago</code>) will have</p>
  
  <pre><code>SELECT "posts".* FROM "posts" WHERE (created_at &gt; '2013-03-06 07:37:09.010916')
  </code></pre>
  
  <p>but how do I <code>SELECT</code> the post and the users so it will return the posts users as well?</p>