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

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

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