title: ActiveRecord find all parents that have associated children
body: <p>I don't know why I can't figure this out, I think it should be fairly simple.  I have two models (see below).  I'm trying to come up with a named scope for SupplierCategory that would find all SupplierCategory(s) (including :suppliers) who's associated Supplier(s) are not empty.</p>
  
  <p>I tried a straight up join, <code>named_scope :with_suppliers, :joins =&gt; :suppliers</code> which gives me only categories with suppliers, but it gives me each category listed separately, so if a category has 2 suppliers, i get the category twice in the returned array:    </p>
  
  <p>Currently I'm using:</p>
  
  <pre><code>named_scope :with_suppliers, :include =&gt; :suppliers
  </code></pre>
  
  <p>and then in my view I'm using:</p>
  
  <pre><code>&lt;%= render :partial =&gt; 'category', :collection =&gt; @categories.find_all{|c| !c.suppliers.empty? } %&gt;
  </code></pre>
  
  <p>Not exactly eloquent but illustrates what I'm trying to achieve.  </p>
  
  <p><strong>Class Definitions</strong></p>
  
  <pre><code>class SupplierCategory &lt; AR
    has_many :suppliers, :order =&gt; "name"
  end
  
  class Supplier &lt; AR
    belongs_to :supplier
  end
  </code></pre>