2
在Rails Guide for associations' has_many section是下面的例子:瞭解Rails的導遊協會例如
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, through: :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, through: :appointments
end
加盟模式的集合可以通過API來管理。例如,如果您分配
physician.patients = patients
新加入模型爲新關聯的對象創建的,如果一些都消失了,他們的記錄被刪除。」
我想了解:
1)在哪裏發生的physician.patients = patients
線
2)誰是被分配給所述??