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.
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,
]
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.