Often enough in the Rails community you hear people saying that following the Rails way of doing things will make life much easier. As the title suggests, this is the book that teaches you how to develop Rails 3 applications in “the Rails way”.
This book is not for beginners. Readers should at least know how Rails works, and preferably even have developed one or two applications as well. The book is organized in the form of a reference, and so if you’re looking for a step by step tutorial, you will be disappointed.
On the other hand, readers who already can develop Rails applications would find this a very interesting book to read. I wasn’t expecting that I would be able to read this book from beginning to end, but I did manage that, although with the amount of information in the book, I can hardly remember a tenth of what I read.
Like Rails, this book is highly opinionated. You will be told that Rspec is the Rails way to test, and that Haml is the Rails way of writing templates, even though Test::Unit and erb templates are the Rails default. In fact, there’s an entire chapter dedicated to Rspec and all the view examples use Haml and not erb. Those who use erb for templates might find the Haml examples a tad distracting.
The content of the book is arranged like this:
The first chapter discusses Rails configurations (bundler, dveleopment/test/production environment etc.) and is followed by a chapter on routing. It’s mostly plain reference so far, telling you what and how Rails works and how to set up your application. The third chapter, on REST and its implementation in Rails, is where this book really started getting my attention. This chapter will tell you all you need to know about why REST is such a big deal in Rails.
Chapters 4 through 9 cover the M and C of Rails MVC — the models and the controllers. ActiveRecord is covered in great depth and the chapter on advanced ActiveRecord is amazing. Reading the section on single table inheritance left me despairing about the awkward ways in which I used to handle ActiveRecord objects that would have been better off being split off into subclasses referring to the same table.
Chapters 10-12 cover the V of MVC – the views and helpers and a chapter on Ajax on Rails. This part too is one that you might use more as a reference than as read-on-the-train-to-work material. Especially the chapter on helpers is rather dry, and Obie himself mentions that it is reference material. In fact, the different helper modules are even arranged alphabetically.
Chapter 13 is on sessions management, and is followed by a chapter covering Authlogic and Devise – the two most popular authentication plugins for Rails. Since Rails doesn’t have a built in authentication system, a quick look at the two most popular plugins makes a lot of sense.
Chapters 15-16 cover ActiveResource and ActionMailer respectively. Frankly, I never really got what ActiveResource is all about, and I’m afraid I still haven’t got the eureka moment after reading this book.
These are followed by a chapter on caching and performance, and one on the testing framework, Rspec — both incredibly useful chapters. The former explains how to use builtin mechanisms in Rails to improve performance and the latter gives a quick introduction to Rspec. Chapter 19 covers Rails plugins and chapter 20 is about background processing in Rails – specifically Delayed Job, Resque, and rails runner.
This 700+ page book covers the Rails framework comprehensively (although it does skip ERB and Test::Unit completely). Like its predecessor The Rails Way for earlier versions of Rails, this book will be one that you will find most Rails developers referring to and quoting over the next few years.
Are there any negatives about this book? I should point out once again that this is mainly a reference for the framework, so some chapters might seem dry if you’re reading cover to cover. (I should also point out that these are the very chapters that you will be turning to when you desperately need reference for how to do something.) For instance, the chapter on helpers should certainly have been cut short and the majority of the content moved to the appendix. But on the whole, I have very few complaints about the book.
So who should buy this book? If you’re completely new to Rails, don’t buy now. (Or better, buy it but read it after you’ve read an introductory book on Rails.) Newcomers will easily be overwhelmed with the in-depth coverage of Rails and the lack of example apps to work on while learning.
That doesn’t mean that beginner level Rails programmers won’t find this book useful. I’m only saying that this wouldn’t be the best book when you’re looking at Rails for the first time. If you have some understanding of Rails, even if it is only one or two toy apps, this book will help you make big leaps in productivity. And experienced Rails programmers will obviously find the exhaustive coverage of Rails very useful.