-1

我试图重定向到患者路径:

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"}

那么您如何在我的参数中看到有一个 patient_id => 1!那么怎么了?

4

1 回答 1

1

patient_id在这里传递,但在参数中,而不是作为局部变量。尝试:

redirect_to patient_path(params[:diagnosis][:patient_id])
于 2013-08-29T13:39:49.357 回答