2012-07-11 64 views
0

如何设定协会入学儿童与父亲,母亲,和两个监护人?Rails 3:如何为一个父亲,一位母亲和最多两名监护人的孩子建立协会?

我知道有很多方法来设置它,但你会怎么做呢?我不太清楚如何设置监护人。我目前正在考虑两种选择,也许你可以推荐第三种选择。

选项1个

Enrollments 
belongs_to child 
belongs_to father 
belongs_to mother 

Children 
has_one enrollment 
has_one father 
has_one mother 

Father 
has_many enrollments 
has_many children 

Mother 
has_many enrollments 
has_many children 

选项2

Enrollments 
has_and_belongs_to_many adults 

Adults 
has_and_belongs_to_many enrollments 
has_many children 
# would have a "relationship: father, mother, guardian" 

Children 
has_one enrollment 
has_one father 
has_one mother 

回答