【发布时间】:2012-07-26 13:53:51
【问题描述】:
我进行了很多研究,但找不到我的问题的答案。我的 Rails 应用程序有以下设置:
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
人们拥有:role 列,即0 或1。
我想获取至少有一个人使用role == 0 和一个人使用role == 1 的所有组。
有什么想法吗?顺便说一句,我正在使用 Postgres。
【问题讨论】:
标签: ruby-on-rails postgresql activerecord rails-postgresql