0

I try to delete a record, a DELETE request is sent to the server but the request seems not correct:

What is done: DELETE /books + body json format

What I expect: DELETE /books/123 + no body

  1. What is really expected in ember-model ?
  2. How can I achieve my expectation (DELETE books/123)
fvisticot
  • 7,936
  • 14
  • 49
  • 79

1 Answers1

1

Looking at the source code, it seams clear how ember-model does the DELETE operation:

deleteRecord: function(record) {
  var primaryKey = get(record.constructor, 'primaryKey'),
  url = this.buildURL(record.constructor, get(record, primaryKey)),
  self = this;

  return this.ajax(url, record.toJSON(), "DELETE").then(function(data) {
    self.didDeleteRecord(record, data);
  });
}

basically the resulting format is: DELETE /books/123 + JSON body. If your backend expects something else then the only way to change it would be to rewrite the deleteRecord for your custom needs. But IMO the simplest thing you could do is to just ignore the JSON body.

Hope it helps.

intuitivepixel
  • 23,302
  • 3
  • 57
  • 51
  • Tx, it works now. In fact issue was due to my url construction. Is it possible with an option to remove the .json for the get ? My custom RESTAdapter need to do: url=url.replace('.json', ''); – fvisticot Aug 03 '13 at 22:22
  • @fvisticot, to separate concerns, would it be possible to post another question with the code of your custom RESTAdapter and I will be glad to help :) – intuitivepixel Aug 03 '13 at 22:34