Chad Fowler’s Rails Recipes: Rails 3 Edition is aimed at developers who need to solve tough problems while using Rails. But Rails beginners also can learn plenty from the 70 “recipes” in this excellent guide.
The 280-page book is divided into seven parts. Busy Rails developers can jump directly to any part that deals with their latest vexation. Those new to Rails also can read the book in any “recipe” order, or they can take it straight through like a textbook.
The seven parts are:
- Database Recipes
- Controller Recipes
- User Interface Recipes
- Testing Recipes
- Email Recipes
- Big-Picture Recipes
- Extending Rails
The author uses a simple problem-solution approach. For example, in Recipe 28, the problem is: “You notice a recurring pattern in your application. You’re writing code for the same actions over and over again in your controllers.” The solution Fowler presents involves learning how to use the Rails versions of macros to create “code that writes codes for you….” by taking “advantage of Ruby’s metaprogramming capabilities.”
He then shows how, noting that “Ruby, like Lisp and Smalltalk before it, allows programmers to easily write code that writes and loads code at runtime.” He adds: “This is a really deep topic, and we’re not going to attempt to dig too deep into it here. Instead, we’ll focus on the details necessary to implement our own Action Controller macros.”
Each recipe spans only a few pages but is presented clearly and is well illustrated with code examples.
Anyone working with Rails or still adding it to their programming capabilities should consider getting Rails Recipes: Rails 3 Edition and keeping it within easy reach.
– Si Dunn