how to permit an array with strong parameters

前端 未结 5 516
说谎
说谎 2020-11-22 13:50

I have a functioning Rails 3 app that uses has_many :through associations which is not, as I remake it as a Rails 4 app, letting me save ids from the associated model in the

5条回答
  •  佛祖请我去吃肉
    2020-11-22 14:37

    I can't comment yet but following on Fellow Stranger solution you can also keep nesting in case you have keys which values are an array. Like this:

    filters: [{ name: 'test name', values: ['test value 1', 'test value 2'] }]
    

    This works:

    params.require(:model).permit(filters: [[:name, values: []]])
    

提交回复
热议问题