0
如果我有一個名爲enrollments
表,這是我目前的基本入學設置:Rails 3.如何在belongs_to關聯中設置相同模型的兩個實例?
class Enrollment < ActiveRecord::Base
belongs_to :father
belongs_to :mother
belongs_to :child
end
class Father < ActiveRecord::Base
has_many :enrollments
has_many :children
validates :first_name, :presence => true
validates :last_name, :presence => true
end
現在我想一個guardian_1_id
和guardian_2_id
添加到enrollments
表。我將如何設置?