Param is missing or the value is empty: ParameterMissing in ResultsController#update

前端 未结 2 664
礼貌的吻别
礼貌的吻别 2020-12-08 21:06

I have a Result that belongs to a Website. After I create the website I also create the result and redirect to its edit page. Here I want to add some more values.

M

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 21:56

    The problem lies here:

    params.require(:result).permit(:data)
    

    From require documentation,

    require ensures that a parameter is present. If it's present, returns the parameter at the given key, otherwise raises an ActionController::ParameterMissing error.

    You are requiring result parameter but it's missing from the params. All your values are inside data param. Removing require should do the trick.

    params.permit(:data)
    

    If you want to keep require, wrap data inside result in forms.

提交回复
热议问题