私は多くのことを調査しましたが、私の質問に対する答えが見つかりません。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
です。
少なくとも 1 人role == 0
とrole == 1
.
何か案が?ちなみにPostgresを使っています。