I'm using Ember Data with the RESTful adapter with a rails backend.
When I delete a record from Ember record.deleteRecord(); record.save()
the DELETE
request goes to the server and the model is deleted, but this error is printed to the javascript console:
Extract requested, but no data given for App.ThisModel. This may cause weird problems.
The response from the server was just render json: true
, so I changed it to render json: deleted_model
which renders the json for the deleted record.
That got rid of the previous error, but now the deleted record is recreated in Ember.
What does Ember expect in the response?
You should send back a 200 with an empty valid json response {}
, any data returned is applied to the record as if they were attributes.
http://emberjs.jsbin.com/OxIDiVU/215/edit
Additionally you can send back a 204 with no response.
http://emberjs.jsbin.com/OxIDiVU/214/edit
jQuery 1.9 no longer treats a response of 200
for a JSON
request as a success. Your server should now be returning a 204
response for DELETE
requests with empty response body.
For a rails server, you can do something like this:
def destroy
@something.destroy!
head :no_content
end
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