Pros: Recipes I’d actually use and insight into Rails
Cons: Give me a minute… I’m thinking
Rating: 5 out of 5
Stop reading this review and go buy the book. Seriously. No? Ok, read the review and decide for yourself. Then go buy it.
I’ve never been much impressed by the language and framework recipe books I’ve read. The recipes are often so specific as to be inapplicable to anything I’m working on, or they’re so self-evident that they needn’t be explained. I only bought Rails Recipes because there were precious few books on Rails available at the time, and I thought I might employ an innovative cold press method to squeeze some blood from the stone.
Little did I know.
Rails Recipes surprised and delighted me. Page after page, Mr. Fowler and his contributing authors laid out recipes that would’ve been directly applicable to most of the projects on which I’ve worked. A wide range of topics is covered, including authentication, session handling, draft preview and saving, dynamic test data generation, time zone handling, localization, and several I’ve left out.
Each recipe consists of credit to the source, a statement of the problem to be solved, a detailed recipe explanation with code, a discussion of the solution, and references to other recipes or material that might be helpful. The descriptions and code are complete enough to use as is or extend and adapt to a variety of projects. I happened to be working on an authentication system when I read the book, and I did find a mistake in the code listing – the signin method at the bottom of page 139 omits the check for request.post? – but this seems to be an exception. All the other code and commands I’ve used from the book work as expected.
To me, the real value of the book is less in the recipes themselves than what they illustrate about using Rails effectively. For example, I’ve written authentication systems for a handful of sites before. I’d have no trouble putting together another one for a Rails application, but for someone new to Rails (which I was), the recipe provides a good introduction to relevant mechanisms like action filters. Some of the later recipes are even better in this respect, such as the recipes for creating ones own rake tasks, generators, and plugins. The “Write Code That Writes Code,” recipe is outstanding, showing how to create macros that follow Rails’ idiomatic style.
This isn’t the kind of book I’ll use every day. However, the view I’ve gotten into how to do things “the Rails way,” as the cool kids are fond of saying, is something I’ll use all the time. If you’re already steeped in Rails and Ruby, you can probably take or leave this book based on whether the recipes themselves intrigue you. If you’re new to Rails, this book offers valuable insight how to get the most out of the framework.