我正在用嵌套表单做Rails 4应用程序。我有带有嵌套字段的表单。创建工作很好:
def create_medical_history
@patient_id = params[:patient]
@medical_history = MedicalHistory.new(medical_history_params)
if @medical_history.save
redirect_to patient_path(@patient_id)
else
render 'new_medical_history'
end
end问题是在其他情况下。首先,在我的表单中定义了@patient变量,所以当我render new_medical_history @patient变量变为零时。
我要把它再传回去。我怎么能这么做?
发布于 2016-02-01 15:18:32
您需要再次定义@耐心,以便为呈现做准备。
例如:
else
@patient = Patient.find_by id: @patient_id
render 'new_medical_history'
end或者任何你需要的东西来重新分配病人。
https://stackoverflow.com/questions/35133912
复制相似问题