Implementing CRUD HTTP style

I’m amazed by how often DHH can keep coming up with newer, simpler, and more elegant approaches to web development that really make you think. In his recent blog entry/keynote he discusses using HTTP’s PUT and DELETE methods to more elegantly model CRUD operations (slides of his presentation are here) and this is a good 3rd party summary of his keynote:

So rather than the old school approach of:

C: POST /people/create
R: GET /people/show/1
U: POST /people/update/1
D: POST /people/destroy/1

he instead suggests doing:

C: POST /people
R: GET /people/1
U: PUT /people/1
D: DELETE /people/1

So simple and so elegant! The PUT and DELETE require a hack because HTML doesn’t support them, however, HTTP does and Rails will abstract that away for you so you don’t need to sweat it. When working with RESTful web services though it should be totally clean. I can’t wait to see Rails 1.2!

This entry was posted in Ruby, Web. Bookmark the permalink.

One Response to Implementing CRUD HTTP style

  1. Tom says:

    Here’s a previous take I did on the subject. Please note the comment I made (right after the original post). It’s an important point that I messed up in the post.

Comments are closed.