I have a model person
and a model group
. There are two kinds of persons: leaders lead a group and participants participate. I need a hbtm-relationship between leaders and groups and a has_many-relationship between participants and groups. Is it possible to do this with the same model, person
by providing some kind of condition (is a leader/is a participant) in the model?
class Person < ActiveRecord::Base
has_and_belongs_to_many :groups
has_many :participations
has_many :groups, :through => :participations
...
end
I would like to do this with one model, person
, because users are either leaders or participants but each user should be a person, i.e. User belongs_to :person
.