Reputation: 523
For json
{
"version":"1",
"configs":[
{
"title":"Good",
"body":"Body"
},
{
"title":"Good",
"body":"Body"
}
]
}
How to permit it with Rails' params.permit
in controller?
I tried
params.permit(
config_setting: [
:version,
configs: [
:title,
:body,
]
],
)
But seems not right.
Upvotes: 0
Views: 347
Reputation: 579
Currently you are permitting a json with the following structure:
{
"config_setting": [
{
"version":"1",
"configs":[
{
"title":"Good",
"body":"Body"
},
{
"title":"Good",
"body":"Body"
}
]
}
]
}
Just add config_setting
node to the data or adjust your strong params block to:
params.permit(
:version,
configs: [
:title,
:body,
]
)
Upvotes: 2