After I save the record using selection.save()
where selection is my model, id is not being set on the model. My current server response is same as the json for show. i.e: selection: {id: <id>}
and other fields. Buy id is not set in the ember data local storage.
I'm using the default RESTAdapter and Rails as backend. (I use jbuilder for JSON)
model is MatchPlayerSelection
and once I save the record, this is the response I send back:
{"match_player_selection":{"id":41298,"user":3,"scheduledMatch":133,"matchPlayerScores":[3697,3696,3694,3698,3704,3719,3712,3709,3717,3707,3714],"captain":3694,"viceCaptain":3709}
How are you testing for the id
getting set? The save
function is async and returns a promise, so you need to resolve the promise before checking the id
.
This will NOT work:
selection.save();
console.log( selection.get('id') );
This WILL work:
selection.save().then(function(savedSelection){
console.log( savedSelection.get('id') );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With