Alt*_*ous 9 ruby activerecord ruby-on-rails ruby-on-rails-3
当使用accepts_nested_attributes_for而不是必须传递"child_attributes"时,我想传递"child".我很确定如果我在控制器中添加了很多逻辑来创建记录和子项,我可以做到这一点.但是,为了保持我的控制器清洁和逻辑应该是的位置,在这种情况下的模型,我想知道如何在执行POST或PUT时切换rails 3以使用此语法.
{
"name": "test",
"child_attributes": [
{
"id": 1,
"name": "test_child_update"
},
{
"name": "test_child_create"
}
}
Run Code Online (Sandbox Code Playgroud)
宁
{
"name": "test",
"child": [
{
"id": 1,
"name": "test_child_update"
},
{
"name": "test_child_create"
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
579 次 |
最近记录: |