-1
我试图重定向到patient_path:重定向到patient_path(..)
format.html { redirect_to patient_path(patient_id), notice: 'Patient was successfully created.' }
但不知何故,这不会工作,我得到的错误:
undefined local variable or method `patient_id' for #<DiagnosisController:0x33bea70>
{"utf8"=>"✓",
"authenticity_token"=>"DH+EXLBAd7bmEE4ahTPPz9GATUMoxrR0RZ5dB4pBtGc=",
"diagnosis"=>{"sicherheit"=>"Z",
"seite"=>"R",
"typ"=>"db",
"beschreibung"=>" Leberabszess durch Amöben",
"code"=>"A06.4",
"patient_id"=>"1"},
"commit"=>"Diagnose erstellen"}
所以你怎么能在我的paramters看有一个patient_id => 1!那么最新错误?
您没有访问哈希表的值。 params [:patient_id]应该这样做。 –
我试过了! –
对不起,没有注意到它也嵌套在“诊断”值中。如Marek的回答所示,你需要做params [:diagnosis] [:patient_id]。 –