3

I'm creating a new user with this:

var transaction = App.store.transaction();
transaction.createRecord(App.User, {
    firstName: this.get('firstName'),
    lastName: this.get('lastName')
});
transaction.commit();

my server is returning

{"first_name":"Han","last_name":"Solo","id":"19"}

but the newly create User's id is null. Either I'm not returning the right result from the server or there is another step I need to do to assign the new user's id.

Devin Crossman
  • 6,816
  • 10
  • 54
  • 96

1 Answers1

2

Your server should rather return the following json string.

{"user":{"first_name":"Han","last_name":"Solo","id":"19"}}
ken
  • 3,675
  • 6
  • 31
  • 45
  • In case someone stumbles across this as I did. More details are in the [documentation](http://emberjs.com/guides/models/the-rest-adapter/). I did some exploring of my own, [here](http://stackoverflow.com/questions/14922623/what-is-the-complete-list-of-expected-json-responses-for-ds-restadapter). – James Andres Mar 02 '13 at 03:20