Rails 4 Unpermitted Parameters for Array

前端 未结 5 781
忘掉有多难
忘掉有多难 2020-12-07 22:07

I have an array field in my model and I\'m attempting to update it.

My strong parameter method is below

def post_params
  params[\"post\"][\"categor         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-07 22:50

    I had the same problem, but simply adding array to permit was not enough. I had to add type, too. This way:

    params.require(:transaction).permit(:name, :tag_ids => [:id])
    

    I am not sure if this is perfect solution, but after that, the 'Unpermitted parameters' log disappeared.

    I found hint for that solution from this excellent post: http://patshaughnessy.net/2014/6/16/a-rule-of-thumb-for-strong-parameters

提交回复
热议问题