-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]。 –