• Home
  • About

stonean

Feeds:
Posts
Comments

REST: Active Record Resource CRUD

January 30, 2008 by stonean

I need to point out that I am new to REST and these posts are simply me thinking through these topics to obtain a better understanding. If you find something I’ve said to be incorrect, please let me know.

Simply put, REST design is about resources. To go further, REST design is about providing access to those resources in simple CRUD fashion. What is CRUD? Well it stands for Create, Read, Update and Delete. The basic actions one can perform on a resource.

Well, we obviously have more than those four methods. In fact the functional CRUD actions are: index, show, new, edit, create, update and destroy. This does not mean that each one of these actions will be seen in the path of the request.

Using a User model as an example:

Action Listing users Show user New user Create users Edit user Update user Delete user
Path /users /users/1 /users/new /users /users/1/edit /users/1 /users/1
HTTP Method GET GET GET POST GET PUT DELETE

As you can see, some of the paths are the same. For example, users/1 can be for showing, updating or deleting. That does seem a little odd, but it’s all about the HTTP method. The method determines the action to be taken.

These actions are part of the design consideration for a REST application. What does that mean? Well, when I am thinking about designing a REST application, I think in terms of accessing the data via a process, not user interaction. This forces me to design the resources in the simplest of manners. At least, that’s my goal. Don’t take this to mean this should ALWAYS be done. I don’t apply an ALWAYS rule to anything, that leads to trouble.

As I encounter more REST related issues I’ll post what I’ve learned. I had started to make a series on REST design, but I didn’t like that idea. It felt like I was restricting myself to continue the topic instead of writing about my most recent discoveries. I’m gonna chalk that up to another lesson learned on blogging.

Note: This is an updated version of the original post.

Posted in REST, RubyOnRails | No Comments Yet

  • Open Source


    Lockdown (GitHub)
    RuHL (GitHub)

  • Recommend Me

  • twitter: stonean

    • I checked my RailsConf proposal status and it's 'under review'. 'Dumb and Dumber' then came to mind: 'so there's a chance, *yeah*'. 19 hours ago
    • Yet another way to waste time in the guise of keeping up to date: http://vurl.me/EIR 3 days ago
    • So I submitted my RailsConf proposal, called it Beyond MVC. We shall see. I do such a bad job talking about myself, the bio sucked. 4 days ago
    • @ubermuda that's good to know, thank you! 5 days ago
    • @chanmix51 cool, thanks! 5 days ago
  • Categories

    classy-inheritance Code Style DataMapper Fusion git Haml Interview Questions jQuery lockdown Merb MysqlUtils Process Quick Tips REST RSpec Ruby RubyOnRails rubytrends Stage thoughts Uncategorized


  • Archives

    • November 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007

Blog at WordPress.com.

Theme: Mistylook by Sadish.