Agile Web Development With Rails
Over the past few months, I've been happily looking at early drafts of Agile Web Development with Rails, the first book on Ruby on Rails by Dave Thomas (author of Programming Ruby and The Pragmatic Programmer) and David Heinemeier Hansson, who we should just call the Rails dude. Some of the chapters were contributed by other members of the Rails community, including Leon Breedt, Mike Clark, Thomas Fuchs, and Andreas Schwarz.
It's a great book. If you want to start with Ruby on Rails, I can think of no better way than buying it (and Pickaxe 2 if you are a Ruby newbie) and working through the hands-on bookstore building exercise in a weekend. Because there's such a demand for a Rails book, David (and what looked like a hundred Rails fans) convinced Dave Thomas to offer a "Beta Book" version -- an early unfinished PDF so developers can use the material. Another great idea. (Addendum: Just looking at the errata page shows how much feedback is coming in. Not only is the book being edited but the Rails API is still moving, e.g. deprecation of render_* and redirect_to_*.)
Aside from covering many aspects of Rails, the book does an excellent job of describing "best practices" in Rails development.1 It's like looking over the shoulder of a seasoned programmer as he guides you through his thought process. A few times early in the review process David would publically give a tip or explain how a naming convention leads to an implicit operation (like auto-timestamping). In the most recent book version, we now have "David Says..." sidebars.
Coming from PHP web development, I was impressed with the attention paid to testing during the book's app building tutorial, and the examples of how Rails knits the full stack (model, view, and controller) together nicely. I've already paid homage to Rails as a web-app language; the beauty of the Rails/Ruby language was on display in the book, particularly in sections like Dynamic Finders in the Active Record Basics chapter. Dynamic Finders are dynamically created finder methods that take their name from model attributes, e.g. Order.find_by_name("Steve Jobs") and Order.find_by_email("jobs@apple.com"). In both cases, the find_by_name() and find_by_email() methods just work because our Order model has attributes for name and email. And you could always search on multiple columns via find_by_name_and_email(); it just falls out of the model. I'm not sure whether I enjoyed this book more because of Dave's knack for explanation or because Dave (and the others) point out all the interesting features of Rails :)
I think the book is friendly to Ruby beginners. There is a twelve page appendix covering most of the Ruby you'll need for the Rails discussion, but you'll definitely want a copy of Dave's Programming Ruby (the Pickaxe book) handy. I wouldn't be surprised if this book accelerates defection from PHP land. Mojavi, an admirable PHP5 MVC web system, was one of the frameworks I was considering before choosing Rails. If you like the approach of Mojavi, you're going to love Rails and Ruby :)
Although Dave released the unfinished book, I don't think a table of contents has been publicized. So here's what the preliminary TOC looks like:
----
1. Introduction
I> Getting Started
2. The Architecture of Rails Applications
3. Installing Rails
4. Instant Gratification
II> Building An Application
5. The Depot Application
6. Task A: Product Maintenance
7. Task B: Catalog Display
8. Task C: Cart Creation
9. Task D: Checkout!
10. Task E: Shipping
11. Task F: Administrivia
12. Task T: Testing
III> Rails in Depth
13. Rails in Depth
14. Active Record Basics
15. More Active Record
16. Action Controller and Rails
17. Action View
18. The Web, V2.0
19. Action Mailer
20. Web Services on Rails
21. Securing Your Rails Application
22. Deployment and Scaling
Appendix A. Introduction to Ruby
Appendix B. Configuration Options
Appendix C. Source Code
----
Section III will be of most interest to current Rails developers. It provides a consolidated review of the framework's most important components and drills down to a level just above the RDoc documentation.
An early congratulations to Dave Thomas, David Heinemeier Hansson, and all the contributors, even if you have some all-nighters ahead :) This is the first of five reportedly upcoming books on Rails, which is truly amazing given Rails hasn't hit version 1.0 yet.
-------
[1] Over the review period, some issues cropped up that may impact "best practices" (for example, Google Web Accelerator and use of non-idempotent GETs). Dave will have to pull the trigger soon to get this book out by August, but hopefully the final version will include some caveats.


