The REST style characterizes communication between system components (where a component is, say, a web browser or a server) as a series of requests to which the responses are representations of resources.
What you actually do get hold of is never the resource itself, but a representation of it.
A resource may, at any given point, be available in any number of representations.
Resources as URLs
A resource is something like a "business entity" in modeling lingo. It's an entity you wish to expose as part of an API. Almost always, the entity is a noun, e.g. a person, a car, or a football match.
Each resource is represented as a unique URL.
Operations as HTTP methods
Services should be stateless
An objective of REST is to be able to switch clients at any time and receive the same result.
So are cookies used at all? Yes, cookies can be used, but mainly for authentication.
They should only affect if the user can make a call, but not how the server responds.
Services should be idempotent
"Idempotent" means that once you pass a message to service, there's no additional effect of passing the same message again.
Benefits of Rails’REST
Convenience and automatic best practices for you
A REST interface to your application’s services, for everyone else
A Short Notice
There’s a temptation to call your actions add_item and replace_email_address and things like that. But things get simpler when you name your actions after CRUD operations, or as close to the names of those operations as you can get.
You will have created four named routes and allow you to connect to seven controller actions.
In most cases, is that they have created a Book model, a book controller with a set of CRUD actions, and some named routes pertaining to that controller (courtesy of map.resources :books ).
Each of routes generated by map.resources takes up memory in your application, and causes Rails to generate additional routing logic.
Luckily, since Rails 2.2 you can use the :only and :except options to fine-tune the routes that Rails will generate for resources. You can supply a single action, an array of actions, or the special :all or :none options.
PUT and DELETE
A PUT or DELETE request, in the context of REST in Rails, is actually a POST request with a hidden field called _method set to either “put” or “delete”. The Rails application processing the request will pick up on this, and route the request appropriately to the update or destroy action.
Allows you to introspect all of the routes your application recognizes.
rake routes command
Imagine, for instance, that you have a resource that could exist only one, a blog. You don’t need an index action for the blog resource, since there is only (and can only ever be) one blog in the application.
map.resource is designed for just this situation. You use it in just the same way as its plural relative.
In some cases—administration interfaces, for instance—you may need to namespace a resource without actually nesting it under another. For example: /admin/posts