[ACCEPTED]-Should deleting a non-existent resource result in a 404 in RESTful Rails?-usability
UPDATE: It turns out I was wrong: https://stackoverflow.com/a/24713946/14731
Previous answer:
HTTP DELETE
is an idempotent operation. Invoking 2 it multiple times consecutively must result 1 in the same behavior as the first. Meaning: you shouldn't return HTTP 404.
I don't think you should ever throw the 23 error at the user for the sake of holding 22 up some standard - especially if this is 21 a consumer facing app (as opposed to B2B). But 20 you also shouldn't make your api change 19 its status code just for this one situation. The 18 resource doesn't exist anymore; so a 404 17 is a proper response.
I think there is a 16 path of least (or lessor - is that even 15 a word???) resistance here. I haven't explored 14 ruby yet so I can't provide any usable implementation; but 13 I'm somewhat experienced with web apps using 12 html/css/js.
If there is some legitimate 11 problem with users clicking a button twice; why 10 not set up the button so that it disables 9 when the request is submitted, and re-enables 8 once the conditions are proper (request 7 has come back)? In other words, avoid the 6 if(this very specific situation) logic by 5 making it impossible to get into the situation 4 you're seeing. I'm assuming ruby has something 3 specifically for handling requests and adding 2 function handlers for different status codes; or 1 at least non-200 status codes.
Rails scaffold code is a suggestion at best. Your 2 instinct to make the error message more 1 user friendly is a good one.
There's no reason you can't return a nicely 11 formatted 404 page with your response. The 10 status code could be the same, just the 9 rendering is more user friendly than your 8 typical 404 page. You could even return 7 the "redirected" page in the response body. One 6 possible problem with this is browser support. It's 5 been quite a few years but I seem to recall 4 IE (6?) completely disregarding response 3 body content when receiving a 404. You'll 2 have to experiment to see what works best 1 for you.
I was thinking about the security aspect 5 of the response provided to the client. If 4 you get 204 you understand that the resource 3 did exist but on 404 you can tell there 2 is no such resource.
Not sure though how 1 this can be exploited.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.