我已经尝试了两天了。如何在控制器中访问表单参数?我正在使用rails 4 form_for。
以下是我的代码。香港专业教育学院尝试了所有评论的方式,但没有成果。我用.ajax调用def patient_params来获取所需的数据。帮助
def new
@patient = Patient.new
@regions = Luregion.all
@districts = Ludistrict.all
end
def update_dis
#@dis = Ludistrict.where("luregion_id =?", params[:luregion_id])
#@dis = Ludistrict.where("luregion_id =?", params[:patient][:luregion_id])
#@dis = Ludistrict.where("luregion_id =?", params[:patient[:luregion_id]])
@dis = Ludistrict.where("luregion_id =?", '#{qaz}')
respond_to do |format|
format.json {render json: @dis}
end
end
def patient_params
params.require(:patient).permit(:fname, :lname, :sex, :dob, :startdate,
:phone, :guardian, :address, :ludistricts_id,
:luta_id, :luvillages_id, :luregion_id)
end
<select id="patient_luregion_id" name="patient[luregion_id]"><option value=""></option>
<input id="patient_luvillages_id" name="patient[luvillages_id]" type="text" /></p>