新手问题 params.require () 问题

ckl · 2014年03月19日 · 最后由 ckl 回复于 2014年03月19日 · 2701 次阅读

permited=params.require(:health_result).permit(:name,:unit) 中的 require()是什么意思,其中内容是从哪里取的?谢谢各位大神帮我这个新手。

https://github.com/rails/strong_parameters

params 就是提交的参数……你看请求时的 log 就能看到实际的值……

<%= form_tag(save_items_health_phy_exam_tpls_path,method:'post') do %> 这是表单, def new_options @phy_exam_tpl = Health::PhyExamTpl.find(params[:id]) end

def save_items @phy_exam_tpl_item = Health::PhyExamTplItem.new(phy_exam_tpl_id: params[:id], category_item_id: params[:category_item_id]) if @phy_exam_tpl_item.save @phy_exam_stand_result = Health::PhyExamStandResult.new(health_phy_exam_stand_result_params) @phy_exam_stand_result.phy_exam_tpl_item_id = @phy_exam_tpl_item.id if @phy_exam_stand_result.save flash[:success]=t("flash.phy_items_add_success") else flash[:danger] = t("flash.phy_items_add_failure") end else flash[:danger] = t("flash.phy_items_add_failure") end end

def health_phy_exam_stand_result_params permited=params.require(:health_phy_exam_stand_result).permit(:name,:definition_type,:unit, :device,:result_type,:normal_max,:normal_min,:result_text,:description) end

但是错误信息提示没有找到 health_phy_exam_stand_result 谢谢大神

需要 登录 后方可回复, 如果你还没有账号请 注册新账号