title: How to query a model based on attribute of another model which belongs to the first model?
body: <p>If I have a model <code>Person</code>, which <code>has_many</code> <code>Vehicles</code> and each <code>Vehicle</code> can be of type <code>car</code> or <code>motorcycle</code>, how can I query for all persons, who have cars and all persons, who have motorcycles?</p>
  
  <p>I don't think these are correct:</p>
  
  <pre><code>Person.joins(:vehicles).where(vehicle_type: 'auto')
  Person.joins(:vehicles).where(vehicle_type: 'motorcycle')
  </code></pre>