How do I find the user that has both a cat and a dog?
- by brad
I want to do a search across 2 tables that have a many-to-one relationship, eg
class User << ActiveRecord::Base
has_many :pets
end
class Pet << ActiveRecord::Base
belongs_to :users
end
Now let's say I have some data like so
users
id name
1 Bob
2 Joe
3 Brian
pets
id user_id animal
1 …