#2に関しては、次のようになります。
form do |f|
f.inputs 'Physician Details' do
f.input :name
end
f.inputs 'Physician Appointments' do
f.has_many :appointments,
heading: false,
new_record: 'Add new appointment',
remove_record: 'Delete appointment',
allow_destroy: true do |app|
app.input :patient, label: 'Choose the patient', collection: Patient.pluck(:name, :id)
app.input :appointment_date
end
end
見出しについて: -falseまたは何らかのラベル(文字列)である可能性があります
allow_destroyについて: -ここに表示されているように、ユーザーの管理者権限をチェックするように設定できます
重要-医師モデルでは、次のことを確認してください
accepts_nested_attributes_for :appointments, allow_destroy: true
そして、アクティブな管理モデルファイル(admin \ physicians.rb)で次のように設定します。
permit_params :name, appointments_attributes: [:patient_id, :_destroy, :id]