“Programming books are pointless: you buy them, you read them and you chuck them because they’re already out-of-date!”
This is a quote from my fiancée, who always pointed out the ephemeral nature of programming books and therefore highly discouraged me from buying any more. The sad thing is that this is partly true: if you buy a new programming book it will eventually become outdated pretty quickly, especially if it’s about newish technologies like Ruby on Rails.
The Rails Way is no exception: Rails 2.2 has been out for a while and introduced a few new features – most notably Internationalization support – which are not mentioned neither in this book nor in others.
That being said, The Rails Way by Obie Fernandez is still the best and most comprehensive book on Rails v2 currently on the market. It’s the book you simply cannot afford to ignore, if you are using (or are planning to use) this popular Ruby web framework.
Before proceeding any further, I’d like to point out that is probably one of the longest programming books I’ve ever come across. With its 910 pages, The Rails Way definitely cannot fit in your pocket and you cannot take it around with you easily. It’s a book made to sit on your desk constantly and remain there, ready to be accessed at the right time, when needed. Unlike with other books I reviewed, this time I won’t even attempt to go through every chapter and every section: it would not be meaningful for the review and it will probably bore you to death. For completeness' sake, however, here’s a very trimmed-down table of contents listing only the first level headings:
- Chapter 1 - Rails Environment and Configurations
- Chapter 2 - Working with Controllers
- Chapter 3 - Routing
- Chapter 4 - REST, Resources, and Rails
- Chapter 5 - Reflecting on Rails Routing
- Chapter 6 - Working with ActiveRecord
- Chapter 7 - ActiveRecord Associations
- Chapter 8 - ActiveRecord Validations
- Chapter 9 - Advanced ActiveRecord
- Chapter 10 - ActionView
- Chapter 11 - All About Helpers
- Chapter 12 - Ajax on Rails
- Chapter 13 - Session Management
- Chapter 14 - Login and Authentication
- Chapter 15 - XML and ActiveResource
- Chapter 16 - ActionMailer
- Chapter 17 - Testing
- Chapter 18 - RSpec on Rails
- Chapter 19 - Extending Rails with Plugins
- Chapter 20 - Rails Production Configurations
- Chapter 21 - Capistrano
- Chapter 22 - Background Processing
- Appendix A ActiveSupport API Reference
- Appendix B Rails Essentials
- Afterword What Is the Rails Way (To You)?
If you already know Rails, these titles will be self-explanatory to you. If not, you’ll just have to trust my words when I say that this book covers every possible aspect of the framework, and 99% of the notions you need to know to start developing almost any Rails-powered web application.
What really pleased me were chapters 17 through 22, i.e. something not strictly related to Rails Core. Normally, books about Ruby and Ruby on Rails don’t deal with anything even a little bit outside their scope: as a result, topics such as Rubygems, RSpec and Capistrano are often not mentioned at all, or if they are, they are relegated to one or two pages at maximum, leaving the reader to look on the Internet for more information. By contrast, The Rails Way covers these ancillary but still very important topics very in-depth. Sure, you won’t know the inside-out of RSpec after reading this book (although a whole chapter is devoted to it), but you will certanly know your way around it enough to use it properly.
What’s missing in this book then? Maybe a Chapter 0 to guide the absolute beginner through the very basics of Rails and Ruby. Probably this goes beyond the scope of the book though, as the author clearly states that the book “[…] is not a tutorial or basic introduction to Ruby or Rails. It is meant as a day-to-day reference for the full-time Rails developer. ”. Still, 100 pages about the Magic of Scaffolding & other tricks to astonish the children wouldn’t have damaged the book, especially considering that Chapter 1 starts at page 60 after a lot of pages intentionally left blank, Introduction, Foreward, Acknowledgements and similar padding material.
Organization and writing style
“Before going on, I should mention that part of what makes Rails exceptional is that it is opinionated software, written by opinionated programmers. Likewise, this is an opinionated book, written by opinionated writers.”
This sentence in the Introduction sounded very familiar. Almost an echo of Zed Shaw’s own words in the Mongrel Digital Shortcut. After all this book is part of the Addison-Wesley Professional Ruby Series, of which Obie is the Series Editor. Like the other books in the series, this book contains all the stylistic conventions and distinctive features which make them very enjoyable to read:
- Informal, almost personal style – reading this book is almost like hearing Obie telling you what he thinks about Rails, and sharing with you his own tips and tricks.
- Honest, even humble at times – This book doesn’t glorify Rails or Ruby: on the contrary, pitfalls are acknowledged and dealt with. Rails lacks an inbuilt authentication system? No problem, a whole chapter is devoted to the act_as_authenticated plugin. You almost feel it’s part of the core itself.
- “[Person] says” sidebars – The book’s co-authors occasionally have their saying in special sidebars, all throughout the book. A way to evaluate different opinions and take a break from the book’s main flow.
- Code snippets – Not too many, not too few, just about the right amount. Granted, you won’t find any sample application in this book, but the snippets provided are more than enough to get to the point.
Although this book is meant to be a reference, this doesn’t mean it only contains reference material, it means that if you don’t know about a particular feature of Rails or its satellites (Capistrano, RSpec, testing in general, etc.) you can open the book at any chapter and read through an in-depth discussion which will, most likely, answer all your questions.
Even if what you’re looking for is not strictly related to Rails but can just be used with it, you’ll find it in the book. Some examples include a 23-page-long exhaustive dissertation on Prototype, a whole Chapter on RSpec, another on Capistrano and even information on XML parsing through REXML.
What you won’t find in the book, unfortunately, is how to get something which was not meant to be seamless integrated with Rails to work, like JQuery, for example. But again, this is understandable, as such topics would have made the book three times longer, at least.
Some constructive criticism
As a technical writer, I was somehow unhappy of the way reference material was presented in the book, i.e. more or less as ordinary chunks of text:
Executes the SQL statement provided in the context of this connection. This method is abstract in the DatabaseStatements module and is overridden by specific database adapter implementations. As such, the return type is a result set object cor- responding to the adapter in use.
Executes an SQL INSERT statement and returns the last autogenerated ID from the affected table.
You’ll find plenty of pages like this in the book. Although all essential the information about each specific method is there, it is not organized properly. When I’m coding and I want to look up something quick, chances are that I can just hop over to APIdock or other similar services and query Rails documentation in a much more efficient way.
On the other end, if reference material was added for completeness' sake, it would have been much better included at the end of the book, more succinctly, through some carefully constructed reference tables. If the aim was instead to help the reader memorize all the method he must know to work productively with Rails everyday, the author should have included some diagrams or any other type of visual aid.
Similarly, the Stack Checklist included in Chapter 20 is not actually a list at all, but rather a sequence of titled paragraphs which is definitely a good read the first time, but it won’t be as useful when you need to just refresh your memory.
I admit, I noticed these things because part of my daily job as Technical Writer consists in making sure that reference material is well presented in the most minimalist, direct and useful way to the reader. Maybe a year ago I wouldn’t have thought anything of it, but now I felt compelled to point this out hoping the next edition of the book will deal also with this aspect of the book.
Since the book came out in 2007, the organization and presentation of Rails Documentation has been significantly improved by third-party services: I hope the authors and editors will try to make sure, next time, that the reference material is more usable by the readers.
Overall, the book is a good read. It’s even possible to read it sequentially (even if the author discourages this practice) and still get the most out of it – a rare trait in programming books nowadays.
No other book will go so in-depth about Rails or about everything you need to know to get your site up and running in a_real production environment. That’s the reason why The Rails Way_is the perfect companion for web development professionals who must ensure their applications are tuned up to perform and scale well.
This doesn’t mean that beginners should be discouraged from reading this book, quite the opposite. This is actually the only book newcomers to Rails need once they are done reading all those awesome beginner-oriented tutorials freely available on the Internet. Everyone interested in Rails, at some point, has to follow The Rails Way.