【发布时间】:2018-12-22 06:21:29
【问题描述】:
我正在使用 Rails 5.2 中的 REST API 并遵循 JSON API 规范。我的 JSON 是这样的:
{
"data":{
"attributes":{
"name":"Gleydson",
"age":"30"
},
"relationships":{
"occupation":{
"data":{
"attributes": {
"name": "Teacher",
}
}
}
}
}
}
我有以下方法user_params:
params.require(:data).require(:attributes)
.permit(:name, :age,
relationships: { occupation: { data: { attributes: [:name] } } })
但是当我打印方法的返回时,什么都没有返回
【问题讨论】:
标签: ruby-on-rails strong-parameters json-api