作者:灬毋黑色灬_447 | 来源:互联网 | 2023-05-17 19:05
Ivegotaprettysimplequestion.Buthaventfoundasolutionsofar.我有一个很简单的问题。但到目前为止还没有找到解决方案。
I've got a pretty simple question. But haven't found a solution so far.
我有一个很简单的问题。但到目前为止还没有找到解决方案。
So here's the JSON string I send to the server:
这是我发送给服务器的JSON字符串:
{
"name" : "abc",
"groundtruth" : {
"type" : "Point",
"coordinates" : [ 2.4, 6 ]
}
}
Using the new permit method, I've got:
使用新的许可证方法,我得到:
params.require(:measurement).permit(:name, :groundtruth)
This throws no errors, but the created database entry contains null
instead of the groundtruth value.
这不会抛出错误,但是创建的数据库条目包含null而不是groundtruth值。
If I just set:
如果我只是设置:
params.require(:measurement).permit!
Everything get's saved as expected, but of course, this kills the security provided by strong parameters.
一切都按预期保存,但当然,这将破坏强参数提供的安全性。
I've found solutions, how to permit arrays, but not a single example using nested objects. This must be possible somehow, since it should be a pretty common use case. So, how does it work?
我已经找到了解决方案,如何允许数组,而不是使用嵌套对象的单个示例。这一定是可能的,因为它应该是一个非常常见的用例。那么,它是如何工作的呢?
3 个解决方案