当使用accepts_nested_attributes_for时,我想传递“child”而不是传递“child_attributes”。我很确定如果我在我的控制器中放入很多逻辑来创建记录和子项,我可以做到这一点。但是,为了使我的控制器保持清洁和逻辑,在这种情况下,模型,我想知道如何在执行 POST 或 PUT 时切换 rails 3 以使用此语法。
{
"name": "test",
"child_attributes": [
{
"id": 1,
"name": "test_child_update"
},
{
"name": "test_child_create"
}
}
相当
{
"name": "test",
"child": [
{
"id": 1,
"name": "test_child_update"
},
{
"name": "test_child_create"
}
}