Ruby for Rails is a book written by David A. Black, a well known guru in the Ruby community
In short: The book is great.
I'd recommend it for all people who have already tried Rails and appreciate its magic, but now want to understand what's going on under the hood.
What is Ruby On Rails?
In case you have lived on another planet for the last year, Ruby on Rails is a web development framework. For those of you who know how Django works you can read a good comparison of Django and RoR.
The structure of the book is organised as follows:
Chapter 1 The Ruby/Rails landscape
Chapter 2 Ruby building blocks.
Chapter 3 Built-in classes and modules
Chapter 4 Rails through Ruby, Ruby through Rails
Quoting the author the goal of this book is:
(..) That's the goal - to be able to bring Ruby skills to bear seamlessly on Ruby tasks. Whether it's writing an action, or a method in a helper file, or a highly specialized suite of methods like the rankings and favorites facility in the music store application, the ideal situation is one in which you have a large number of programming techniques at your command and you use whichever ones help you get your application to do what you want it to do.
Having finished this book I feel that not only my Ruby skills got enhanced but also I understand more about Rails code. It's much easier now to follow the discussions about creating DSLs using Ruby and also actually creating my own DSLs. Even though not all of the Rails features are covered in the book, (like migrations or plugins) I'm able to see how simply they are designed. It wasn't easy, though (almost 500 pages). Finishing this book took me some time. I tried to follow most of the examples in the book but it was worth the time spent on it.
I really enjoyed the chapters about dynamic programming. They cover the whole family of eval methods, the singleton class. All of these are heavily used when you want to create a DSL.
Another very useful chapter for me was the one about regular expressions. I'm this type of developer who keeps forgetting details how to prepare a more complex regex.
Thanks to the Ruby for Rails book I feel the Ruby way better. I think it's very important to understand the whole philosophy of a language. I remember (back in December 2004) my first Ruby on Rails code was either looking exactly as in tutorials or when I needed to build something more complicated it was actually Java coding using Ruby ;-) I was in a similar situation when I started working with Python. It was very tempting to just code Ruby using Python. Thanks to Michael's patience I think I'm getting better with Python now :-)
Let's take the following Rails code as an example:
class Edition < ActiveRecord::Base
All Rails newbies can tell you what this code does. I'm not really so sure if all of them are able to explain how is it actually done under the hood.
I like to call Rails a DSL for creating web applications. Despite the whole simplicity it provides it also means it is an additional layer of abstraction.
Quoting Joel Spolsky :
All non-trivial abstractions, to some degree, are leaky.
We must understand how is the abstraction created so that when in a need we can easily fix any problem that appears during Rails development.
Ruby for Rails is an excellent book. It covers all important topics about Rails development and highlights the Ruby way. If you already created some Rails applications but still feel there is some magic around you definitely should read this book.