title: Create scope for many to many relationship rails
body: <p>I want to create scope in Company model, so that I can use this line</p>
  
  <pre><code>Company.customer
  </code></pre>
  
  <p>in order to select all company which has customer type.</p>
  
  <p>The relationship between Company and CompanyType is many-to-many.</p>
  
  <p>Company:</p>
  
  <pre><code>class Company &lt; ActiveRecord::Base
    attr_accessible :description, :name, :website, type_ids
    has_and_belongs_to_many :types, :class_name =&gt; "CompanyType"
    #scope :customer, where()
  end
  </code></pre>
  
  <p>CompanyType:</p>
  
  <pre><code>class CompanyType &lt; ActiveRecord::Base
    attr_accessible :name
    has_and_belongs_to_many :companies
  end
  </code></pre>
  
  <p>For the table in the database, I have table "company_types", "company_types_companies" (connection table between company_types and companies) and "companies"  </p>
  
  <p>How do I fill in :customer scope in Company model?</p>