Datasheet

Chapter 1: Building Resources
38
Resources
The primary source for the REST details in this chapter was the RESTful Rails tutorial, written by Ralf
Wirdemann and Thomas Baustert and translated from the original German by Florian G ö rsdorf and
Adam Groves. It s available at
www.b-simple.de/documents . It s an excellent reference for the details
of the Rails version of REST.
For more details on recipes in general, I reference The Joy of Cooking by Imra S. Rombauer, Marion
Rombauer Becker, and Ethan Becker. The well - worn copy in my house was published by Scribner in
1997. I also recommend
www.cookingforengineers.com , run by Michael Chu.
A full listing of all the
assert_select codes can be found at http://labnotes.org/svn/public/
ruby/rails_plugins/assert_select/cheat/assert_select.html
, which is maintained by Assaf
Arkin.
The CSS and text layout come from
www.freewebtemplates.com .
Summary
In this chapter, you start with nothing and finish with the beginnings of a recipe - sharing website. The
initial data design sets the pattern for the remainder of the development.
REST is a structure for organizing web pages by resource, with a common set of commands for accessing
the basic Create, Read, Update, Delete (CRUD) functionality for each resource. REST also allows for URL
patterns to be common from resource to resource, and depends on the specific HTTP method of the
request to determine what action the server should take in response to a URL.
Rails supports REST by easily scaffolding the creation of a REST model and its associated controller. A
single element in the
routes.rb file specifies an entire suite of RESTful routes for the resource. These
routes can be seen using the
rake routes command. Resources can be nested, in which case the child
resource URLs always contain an instance of the parent resource.
The basic application is augmented in this chapter with some server - side intelligence to make entering
data easier for the user. An in - place editor is added using basic Ajax techniques, and unit and functional
tests are written for all new code.
c01.indd 38c01.indd 38 1/30/08 4:02:32 PM1/30/08 4:02:32 PM