Unpermitted parameters in rails 4

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

I read about collection_check_boxes but I don't understand how can I set the checked values. I have the following model:

class Objective 

edit view:

        

the html checkbox are ok but I don't know how to set the values to objective. I was tried define objective_ids= objectives_ids but nothing happens.

In Controller:

class ObjectivesController 

EDIT The log file says Unpermitted parameters: perspective_id, objective_ids

回答1:

I solved changing the line

params.require(:objective).permit(:name, :code, :description, :objective_ids) 

to

params.require(:objective).permit(:name, :code, :description, :objective_ids => []) 


回答2:

I get the same problem, try this line:

params.require(:objective).permit(:name, :code, :description, :objective_ids => []) 

but does not work and i change to:

params.require(:objective).permit(:name, :code, :description, {:objective_ids => []}) 

and it works !!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!