Rails 4, strong parameters, nested resources, build and undefined method permit

谁说我不能喝 提交于 2019-12-04 16:43:50

This is happening because Rails by default send a :action param containing the action that was requested. When you do params.require(:action) you're actually returning the name of the action requested as a string, in this case, create. You can explicitly tell form_for to use another key for the hash, solving your strong parameter problem:

<%= form_for [@project, @action], as: :foo do |f| %>

And in your controller:

params.require(:foo).permit...

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