I have a REST API consumed by an ember app. Here is the .hbs which lists a model. I can give new elements with the "save" action, and every item has also a "delete" action.
{{ input value=name }}
{{ input value=value }}
<button {{ action "save" this }}>Save</button>
<table class="table">
{{#each item in model}}
<tr><td>{{item.name}}</td><td>{{float2 item.value}}</td><td><button {{ action "delete" item}}>delete</button></td></tr>
{{/each}}
</table>
So far works everything fine. The problem if i insert (save) a new element, i cant "delete" it, it has id:null, and the request to the api has no id at the end of the URL. (although on the client side the item will be removed from the list)
here is the controller's actions:
actions: {
save: function (record) {
var vat = this.store.createRecord('vat',{
name: this.get('name'),
value: parseFloat(this.get('value'))
});
vat.save();
},
delete: function(record){
console.log(record);
record.deleteRecord();
record.save();;
}
}
My guess is after the insert the API doesnt have the correct response, and ember-data doesnt know the new item's id. (maybe im wrong) what respons (JSON structure) expects the RESTAdapter, with which status code?