Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 How can I allow nested attributes to be passed without the _attributes designation

When using accepts_nested_attributes_for, instead of having to pass "child_attributes", I'd like to pass "child". I'm pretty sure if I put a lot of the logic in my controller to create the the records and children, I could accomplish this. However, in an effort to keep my controllers clean and logic where it should be, the model in this case, I'd like to know how to switch rails 3 around to use this syntax when doing a POST or PUT.

{
  "name": "test",
  "child_attributes": [
    {
      "id": 1,
      "name": "test_child_update"
    },
    {
      "name": "test_child_create"
    }
}

Rather

{
  "name": "test",
  "child": [
    {
      "id": 1,
      "name": "test_child_update"
    },
    {
      "name": "test_child_create"
    }
}
like image 471
Altonymous Avatar asked Aug 10 '12 15:08

Altonymous


1 Answers

Evidently, this can't be done.

like image 155
Altonymous Avatar answered Oct 12 '22 23:10

Altonymous