Devin Crossman
Devin Crossman

Reputation: 7592

Ember assign id to created record

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.

Upvotes: 3

Views: 1586

Answers (1)

ken
ken

Reputation: 3745

Your server should rather return the following json string.

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

Upvotes: 2

Related Questions