O'Reilly logo

Ruby on Rails® for Microsoft Developers by Antonio Cangiano

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.3. A RESTful Application

The file config\routes.rb defines how URLs are mapped to controllers and their methods (actions, in Rails speak). For example, in the previous paragraph you mapped the controller Articles with the root of your Rails application.

In traditional Rails applications — if the word "traditional" can be used for such a young framework — URLs have the following format by default :controller/:action/:id, as briefly discussed in Chapter 2. So /articles/show/3 would trigger the show action defined within the ArticlesController and pass a parameter id to it, whose value is 3. Similarly, /articles/edit/3 would trigger the edit action of the same controller on the same object, and /articles/update/3 would do the same for the update action.

Defining URLs in this manner is still possible today with the current version of Rails, but it means thinking in terms of pages that you access and upon which you perform certain actions that send a request and receive a response back. This approach works and it's the traditional way of doing Web development. Even the ASP.NET event-based model, despite its many differences, essentially leads developers to think in terms of pages (WebForms).

5.3.1. What's REST?

Rails has clearly embraced "the REST way" of doing Web development. REST stands for REpresentational State Transfer and it's a set of principles that define the style of software architecture for distributed networks such as the Web. What this means in practice is that you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required