I have researched a lot and I can't find the answer for my question. I have the following setup on my Rails app:
class Group < ActiveRecord::Base
has_many :people
# ...
end
class City < ActiveRecord::Base
has_many :people
# ...
end
class Person < ActiveRecord::Base
belongs_to :city
belongs_to :group
# ...
end
The people have the column :role
that is 0
or 1
.
I want to get all the groups that have at least one person with role == 0
and one person with the role == 1
.
Any idea? I'm using Postgres by the way.