Obie did it, again. With the second edition of his former masterpiece, The Rails Way, he managed to outdo himself delivering a new, even more useful, Rails Bible. Wether you’re a Ruby on Rails professional like him or just an enthusiast, this book is pretty much everything you need to learn how to master the third release of DHH’s Ruby web framework.
The Rails 3 Way is no ordinary second edition. If you already own The Rails Way, you’ll be pleasantly surprised that this is a different, more polished book. While something had to remain the same, there’s a lot of new content in its 708 pages, and even the old content has been rewritten or at least revised.
It doesn’t matter whether you already know Rails 2.x or you’re jumping straight into the Rails 3 world, if you use Rails, you can’t miss this book.
I started the review of the first edition with a quote from my fiancée (now wife) on how pointless programming books are, especially those dealing with newish technologies: they tend to go out of date fairly quickly. While this still holds true, there’s not much you can do about it, except maybe purchasing a digital edition of the book instead. However, if you want to keep a good Rails reference book by your side, this has to be the one.
If you put The Rails 3 Way and the original The Rails Way one next to the other, you can see that the new book is considerably shorter: about 200 pages less. This doesn’t mean it contains less information, quite the opposite: the new book contains a lot more stuff with less fluff. Obie managed to reduce digressions to a bare minimum and focus on providing more informative content to the readers using less text. Think of it as a fat-free book.
Although the book is divided into chapters, it can also be divided into parts (each dealing with a specific theme) simply by looking at the front edge. According to this theme-based partitioning, Active Record makes up for nearly a quarter of the book (173 pages), followed by Active Support API appendix and the All About Helpers chapter.
Another nice addition that can really make the difference when you’re in a hurry is the Method Index, which is separate from the main Index. It seems to account for all the methods in all (or at least the most important) classes in Rails. I didn’t check method by method, but it is pretty comprehensive nonetheless, based on some quick spot checking.
The first thing you notice once you read the first few pages, is that this book is even more opinioned than its predecessor.
Even though Rails 3 is less opinionated than early versions, in that it allows for easy reconfiguration of Rails assumptions, this book is more opinionated than ever.
– Obie Fernandez, Introduction to The Rails Way
In other words, you won’t find an ERb view in the whole book (Haml rulez!) and if you don’t like RSpec… well, you’d better skip Chapter 18 altogether.
The other big difference with traditional Ruby and Rails books is the amount of reference to third-party code, mainly rubygems. Rails comes with no authentication functionality? So what: Authlogic and Devise are great for the job, go check them out! Do you need to test your Active Mailer emails? email-spec is all you need.
I was actually surprised to find so much content not strictly related to Rails in this book: the first chapter starts off with Bundler (now a Rails dependency, however), Chapter 2 (Routes) mentions Rack, and so does Chapter 4 (Controllers). If you want a nice and to-the-point practical introduction to RSpec, the first part of Chapter 18 covers that.
Then there’s reference material. Plenty of it, a good 40% I daresay. The good thing is that (unlike the first edition) it won’t bore you to death: take Chapter 5 (Working with Active Record) for example, you’ll fly through find-related methods so swiftly you’ll regret when it’s over. Active Support? I didn’t read every line of Appendix B, but when I want to know something about inflection methods I will know exactly where to find them, and what to expect: the method signature, a few lines of text, and a short example at most.
My only regret? Cheat sheets. Or better, the lack of them. More tables, please! Granted, the web is full of Rails cheat sheets, but a few of them at the end of the book or even in a separate foldable add-on like in the Pragmatic Programmer can’t hurt.
Finally, some words about the code examples. The code/text ratio is almost 1:1, but Obie’s choice of not turning this book into a huge tutorial by implementing a single example application was absolutely right: The code snippets used in throughout the book are concise and relevant to the text around them and won’t distrupt your reading. If you want to play with them, they’re even on GitHub for you to clone and fork.
Organization and Writing Style
The Rails 3 Way is a book for Rails professionals. If you don’t know Ruby or if you never heard of Ruby on Rails, this book is not for you. It won’t teach you what MVC is, it won’t waste time on explaining convention over configuration, it won’t even describe the structure of a Rails app! If you’re newcomer to Rails… well, that’s what The Rails Tutorial is for.
To be honest, I’m with Obie on this. If this book had been beginner-friendly, it would have been even longer than the previous edition, and probably more boring. Instead, by assuming that the reader has been already initiated to the world of Ruby and Rails, the author can dive into the framework straight away. Moreover, chapters are not ordered by difficulty: they don’t need to be, they need to be ordered in a way that makes sense for a Rails developer.
Once again, this book includes personal sidebars used to voice the opinion of one of the co-authors or Rails gurus: there are plenty of “Yehuda says”, “Xavier says”, “Durran says”, and so on. Nothing new there, it’s just a nice way to provide the reader with authoritative opinions on some matters.
As I progressed through the book, I started noticing how Obie anticipated my questions and doubts: I found this to be a remarkable feature of this book, and an excellent way to make the readers feel they are on the same page with the author. If something should not be done because it may cause you problems, the author won’t hold back. See page 214, “Extra Columns on has_and_belongs_to_many Join Tables”, for example: it’s a cool feature, but it can cause all sort of annoyances, and the bottom line is: use has_many :through instead, if you need extra columns on join tables.
The Rails 3 Way remains the de facto reference book for Rails. I was quite pleased to see that Obie improved it so much, compared to the first edition. Sure, it cannot be recommended to absolute beginners, but it’s not a big problem: if you’re new to Rails, all you have to do is browse around and read a few basic tutorials first.
What I really missed was a What’s New section, or something like that. The new stuff that was introduced in Ruby on Rails v3 is seamlessly blended with all the rest, which is great if you’re tackling the framework for the first time, but not so much when you already read tons of books on Rails 2.×. I would have tagged content specific to Rails 3 in some way at least, for example with labels on the side of each page. Or maybe have a short introductory chapter covering the new features, and directions on where to find them in the book.
Overall, The Rails 3 Way is a great book, and if you plan on using Rails 3 for your next web site, it deserves a special place on your desk.