title: Rails where clause over two tables
body: <p>I have the following model in rails application</p>
  
  <pre><code>category =&gt; company =&gt; store
  </code></pre>
  
  <p>Store has a <code>belongs_to</code> company and company has a <code>belongs_to</code> category relationship.
  now i want to use a where method on a store object to retrieve all stores within the same category.</p>
  
  <p>I would like to have something like this</p>
  
  <pre><code>@stores.nearbys(5).where("stores.company.category_id = xxx")
  </code></pre>
  
  <p>can somebody give me a tip on this</p>