Section 4. RESTful Controllers

4.1 A RESTful Controller 314.2 Automating RESTful Controller Generation 344.3 respond_to 404.4 How Content Type Negotiation Works 46

4.1 A RESTful Controller

When writing RESTful Rails applications, the unifying theme is the CRUD controller architecture, which dictates that controllers have the following methods with corresponding URLs.

image

Of course, the preceding code references multiple actions at one URL, something that cannot be done without RESTful Rails. Multiple methods on one URL are accomplished with the new map.resources command in routes.rb. This command enables method choice, not just on URL, but also on ...

Get Rails Refactoring to Resources: Using CRUD and REST in Your Rails Application now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.