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

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -