activerecord - Rails 3: has_many and where -
i have following models
class city < activerecord::base has_many :dealers end class dealer < activerecord::base belongs_to :city end
i need find cities have dealers. how go writing where()
desired results?
to find cities have dealers:
city.joins(:dealers)
if city has no dealers not returned in results.
Comments
Post a Comment