Skip to Content
Ruby on Rails® for Microsoft Developers
book

Ruby on Rails® for Microsoft Developers

by Antonio Cangiano
April 2009
Intermediate to advanced content levelIntermediate to advanced
479 pages
12h 55m
English
Wrox
Content preview from Ruby on Rails® for Microsoft Developers

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Michael Hartl

Publisher Resources

ISBN: 9780470374955Purchase book