Rails Guides の例で遊んでいます:
http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association
この例では、モデルに対して次の設定が行われています。
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
次の2つのことを行う方法を理解しようとしています。
- 新しい患者を作成し、予約時間のある既存の医師に予約を割り当てるビューをセットアップするにはどうすればよいですか
- 既存の患者に、新しい医師と予約時間の予約を割り当てるにはどうすればよいですか
入れ子になったフォームを処理する RailsCasts 196 と 197 を調べましたが、この状況にどのように適用されるかわかりません。
誰かが例を提供するか、これに関するガイドを教えてもらえますか?
ありがとうございました