8.3. RESTful Routes
REST (REpresentational State Transfer) was already introduced earlier in the book when you developed the basic blog application. This section briefly recaps how this new paradigm affects Rails' routing.
RESTful routing is considered to be the new standard for Rails applications and, whenever possible, it should be favored over the traditional style described so far. In short, RESTful routing doesn't simply match a URL to code within the controller, but rather maps resource identifiers (think URLs) and HTTP verbs to seven predefined actions. These actions normally perform CRUD operations in the database as well, through the model layer.
RESTful routes can be defined through the resources method. Consider this route:
Whenever you need to declare more than one resource, you can do so on a single line by passing a list of symbols (for example, map.resources :books, :catalogs, :users) to resources.
This manages to pull off a fair bit of magic, by abstracting and hiding many of REST's implementation details, as well as providing you with named routes and easy-to-use helpers to work with. A single concise line creates seven RESTful routes, as shown in the following table.
|Route Name||HTTP Method||URL||Action in BooksController|
Each named ...