Using rest via rails

Daniel,

It would be helpful to have a bit more detail about your needs. Are you looking for general information on REST as a concept, the particular implementation of REST in Rails, or do you need specific information on the REST implementation of this website that you mentioned.

For information on REST itself there are many articles available on the web about this emerging standard. For information about Rails' implementation of REST there's a general overview in the "Agile Web Develop with Rails" book. Another possibly good resource is the screen casts over at Peepcode. I haven't watched it yet, but I hear it's good. For a "Big Picture" view of REST and why Rails has begun embracing it, watch DHH's keynote here: ScribeMedia — Men's Health Magazine

However, it sounds like you need to communicate with an existing REST web service. That's going to be dependent on that service's implementation of REST. Your best bet there is try to find documentation on using their REST interface.

I've been seeing a lot of information on REST lately and much of it seems very confused. There appears to be much confusion about what REST really means.

I like to think about it this way:

First, put aside the idea that you are dealing with a database. The database is just a repository to store and retrieve a set of resources. Instead think about your application in terms of "resources."

Lets speak in terms of a "book" as one of your application's resources.

You want to perform a set of operations on books: 1. Create new books. 2. List all, or some, of the exiting books. 3. Get one particular book. 4. Make changes to existing books. 5. Delete books.

In terms of Rails these operations might translate to the following URLs: 1. POST: http://localhost:3000/books 2. GET: http://localhost:3000/books 3. GET: http://localhost:3000/books/123 4. PUT: http://localhost:3000/books/123 5. DELETE: http://localhost:3000/books/123

Notice how some of these URLs refer to your "collection" of books and others refer to a particular member of the books collection.

Then there are a couple of additional URL needed to deal with resources not directly related to book, but are needed due to the nature of the web: 1. GET: http://localhost:3000/books/new 2. GET: http://localhost:3000/books;edit

I'm not quite sure why the Rails team decided to use "http://localhost: 3000/books/new" instead of "http://localhost:3000/books;new" but that's just something you have to remember. Those extensions to the GET operations like "/new" or ";edit" can be thought of as "hints" to your application that you are asking for the HTML form for either entering a new book or modifying an existing book. The HTML forms can be thought of as another type of resource in your application that you are "GETting."

Pretty much everything else in RESTful Rails is simply an extension to these basic concepts. There are methods for generating the various URLs like books_path() and books_url(). You can find a nice overview of those in the free REST cheat sheet available from peepcode.com.

There is also the concept of "nested" resources, but I won't go into details on that here. There are other resources (I've mentioned a few) that go into detail on those. They also discuss how to extend your REST routes beyond the basic CRUD operations.

Hope that helps.

Robert