Book Review: “Ruby For Rails” - David A. Black
- Title: Ruby For Rails Buy it at BAMM!
- Author: David A. Black
- Publication Date: May 2006

Most new Ruby on Rails (RoR) developers figure that their first book should be “Agile Web Development with Rails - Second Edition”. While this may be true for developers who have had exposure to Ruby, most new RoR developers will be coming to the framework with no Ruby exposure. Ruby For Rails is meant to address this problem.
I found RoR in late ‘06, and (luckily) Ruby For Rails was my first Ruby book on the subject. I previously had no exposure to Ruby, but had developed extensively in Perl, C/C++, and Shell on Unix platforms. In retrospect, without the aid of this book, my Rails development skills would have been much slower to mature.
Chapter List
- How Ruby works
- How Rails works
- Ruby-informed Rails development
- Object and variables
- Organizing objects with classes
- Modules and program organization
- The default object (self) and scope
- Control flow techniques
- Built-in essentials
- Scalar object
- Collections, containers and enumerability
- Regular expressions and regexp-based string operations
- Ruby dynamics
- (Re)modeling the R4RMusic application universe
- Programmatically enhancing ActiveRecord models
- Enhancing the controllers and views
- Techniques for exploring the Rails source code
Part 1 - The Ruby/Rails Landscape
Chapters 1, 2, 3
David Black starts off with an introduction to Ruby (Chapter 1), mainly from a scripting programmer’s viewpoint. There are no objects, just inline Ruby code. He covers basic “hello world” topics, command line parameters, “require”-ing and “load”-ing files, gems, etc. Advanced topics that get coverage here are:
- Writing extensions
- Debugging
- Profiling
- ri and RDoc
Chapter 2 introduces the reader to RoR, providing just enough web development background information to explain how RoR addresses the pain point of traditional web development. This chapter is where the first RoR application is built. This book was written while migrations were still in their infancy, and thus all of the database creation and population is done with SQL statements, rather than migrations. Black makes a good point (p65), in that every RoR developer should be comfortable with SQL, even if it’s not their primary focus.
Once the RoR application is built, Chapter 3 is used to frame in the scope of the rest of the book. Black addresses some of the problems that can be solved with RoR, and also covers problems that (at the time of writing anyway) were particularly hard to solve with RoR.
Part 2 - Ruby Building Blocks
Chapters 4, 5, 6, 7, 8
Part 2 of the book addresses Ruby with particular attention paid to those parts of Ruby that are heavily used in RoR development. The reader is in no way shortchanged with the RoR focus, though. Coverage is good, and the code examples are clear and well marked. I especially like the way that code segments of interested are indicated with numbers, and then those numbers are referenced in the text when needed. His use of “reverse video” for the numbers draws your eye to the appropriate code effectively.
Part 3 - Built-in Classes and Modules
Chapters 9, 10, 11, 12, 13
As is the case with any language, the language is only as good as it’s library support. Part 3 of the book covers Ruby’s built-in classes and modules, again weighted toward what a RoR developer would most likely encounter. The examples (as before) are presented with irb. Black covers everything from Arrays, to Regular Expressions, to Dynamic Programming.
In the (relatively) short distance from page 96 to page 367, Ruby For Rails presents a slightly distilled view of what the Pickaxe book (Programming Ruby) presents. There’s no reference section (which takes up a good part of Pickaxe), but the examples are fresh, and the presentation is very easy to follow.
Part 4 - Rails through Ruby, Ruby through Rails
Chapters 14, 15, 16, 17
This is the RoR centric part of the book. Here, Black revisits the R4RMusic application, and goes through several iterations of adding functionality to R4RMusic. He covers changes to views and controllers, creating partials, and even a login and signup system.
Review Summary
This book has a few problems, but most of them stem from the rapid pace of RoR development that’s gone on since it was written. The book was written one and a half years before this review, and in that time, RoR has acquired REST, lots of AJAX goodness, rspec, and many others.
This book does not cover Test Driven Development (TDD) which was very prevalent at the time of writing. As mentioned above, it doesn’t cover REST or AJAX either.
The portion of Ruby that’s covered in this book, however, makes up for any omissions of RoR topics. This book remains a great first book for a new RoR developer. This book does not, however, replace the Agile book. Ruby For Rails provides a great introduction to RoR, and most importantly, a solid foundation in Ruby.
September 12th, 2007 at 1:06 pm
So give me a list of the top three RoR books you would recommend.
September 12th, 2007 at 1:16 pm
Ruby for Rails
Agile Web Development with Rails - Second Edition
RESTful Rails from Peepcode (http://www.peepcode.com)
REST is one of the newest techniques to deliver maintainable Rails code, and Peepcode does a *great* job in their screencast. It’s only $9, and includes a ton of code. I’ve seen the first rspec screencast from peepcode, and it’s good, but not nearly as information packed as the RESTful Rails one.