Rails 1.2, REST, and Resources 1
Posted Friday, January 19, 2007 20:27
Today marks a milestone for the Ruby on Rails community: version 1.2 (actually 1.2.1) has been released. For many months, developers who can get away with it have been using the “edge” version because of all the features that have been added since the release of 1.1.6, the last “stable” version, last August (and 1.1.6 had mostly minor changes from 1.1, which came out last March). Now that 1.2 is out, everyone has a stable version with the new features and gains some isolation from the daily evolution of the framework. For people running production sites, it no doubt feels a lot more comfortable being able to move to a new official release than using edge, so the new features are now much more usable for them.
It’s interesting to note how long a time “since last March” seems in the Rails world. In the shrink-wrapped software world, it wouldn’t even be nearly time for a new release, and little or nothing would be known about what was going to change.
For a good rundown of the key new features, see DHH’s blog post. For some more details on specific new features, see:
RESTful Goodness
Support for RESTful routing is one of the central features of Rails 1.2. In essence, this comes down to two things:
- Using the HTTP “verbs” of GET, POST, PUT, and DELETE to enable a single URL to perform multiple functions
- Using the Rails “respond_to” method to enable a single action to respond to requests for HTML, JavaScript, XML, RSS, and so forth
If you’re wondering what the point of all this is, I highly recommend watching DHH’s keynote from the mid-2006 RailsConf. You can view the video at ScribeMedia, though the video is really only useful for the audio, since it doesn’t show the slides. To follow the talk, you need to be looking at the slides, which you can get here. The slides really need the audio to go along with them, so I’d suggest looking at the slides while listening to the audio from the video.
For a detailed example of implementing RESTful routes, you can buy Geoffrey Grosenbach’s PeepCode Screencast for a mere $9. It’s well worthwhile if you want a nitty-gritty example, though I found DHH’s talk better for appreciating the “why” of all this. Geoffrey also offers a free cheat sheet.
If you just want to peruse the code for a complete RESTful example, check out the RESTful Product Tracker code from Zack Chandler.
For a more general description of what REST is about (with a bit of a Java slant), see REST in Plain English.
Books Covering Rails 1.2
Many of the current Rails books were written for 1.1.6, but the second edition of Agile Web Development with Rails is fully 1.2-compliant. (If you’ve been getting by with the first edition, it’s time to upgrade.) Also just out is Rob Orsini’s Rails Cookbook, which Rob held up for a few weeks so he could update it for 1.2.
Prototype 1.5
Along with Rails 1.2, version 1.5 of the Prototype Javascript framework (which is included in Rails 1.2) was released, along with a new web site and better documentation to support it.
