Learn'Ruby for Rails' by David Black


Tom Armitage
writes on July 30, 2006

There’s no denying the stir that Ruby on Rails has caused in the web development community. Since its release in 2004, it has gained a rapidly expanding user-base through its lightweight, elegant code, and marked benefits for productivity. It has also raised the profile of Ruby itself, the dynamic, object-oriented scripting language first released in 1995 by Yukihiro “Matz” Matsumoto. Ruby has been hugely popular in its homeland of Japan for a long while, but only began to gain popularity in the West in the last six years.

So not only are users coming new to Rails, but also to Ruby itself. David Black’s Ruby for Rails aims itself squarely at that sizable audience. It is not so much a book about “Ruby specifically for Rails” as one about “Ruby for people who have come to it through Rails”. Whilst many Rails users quickly get their heads around its clean-cut, minimal syntax, the first problem they often run into is Ruby itself. Ruby is a highly idiomatic language, and does not resemble the C-like languages most people are familiar with. Given the ever-increasing popularity of Rails, this book could not have been published at a better time.

The book takes the form not of a reference, but a linear tutorial. The first handful of chapters look, in turn, at the very basics of writing and running Ruby scripts (along with a quick guide to the Ruby command-line interpreter), the very basics of getting a Rails app up and running, and concludes with a look at beginning to use simple Ruby scripting techniques to enhance you application.

The book then takes a marked turn away from Rails, and concentrates on getting down to the nitty-gritty of Ruby itself. These chapters are the real highlight of the book – not for the keywords and methods they teach, but for the way in which they explain Ruby’s core and abstract concepts. Ruby’s real strengths – its highly dynamic nature and complete object orientation – are potentially its most confusing concepts, and yet Black’s methodical, plainly-written approach lays their complexities bare. His explanations of Objects, Classes, Modules, and how inheritance works are probably the best I’ve seen yet for Ruby, and coupled with an excellent chapter solely devoted to scope and self (the default object), get the complex underpinnings of the language out of the way in a very accessible style. (The sample chapter, on the basics of objects and classes, should give you a feel for Black’s clear, authoritative tone).

After that, the book moves on to cover control flow, devoting a good number of pages to the key concept that is code blocks, and then some slightly less complex chapters cover variables, scalars (strings, numbers, and symbols), collections (arrays and hashes) and regular expressions; these share more in common with languages the reader may be more familiar with. Still, just like the very first introductory chapters, they are all worth reading to the end – whilst they may start with common concepts, by the end, every chapter touches on the aspects that make Ruby unique, and explains some of the deeper complexities.

The Ruby language section ends with another fine, complex chapter, looking at Ruby’s capabilities as a dynamic language. In this chapter, as well as getting a handle on some really idiomatic Ruby concepts, the ‘magic’ present in Rails really starts to fall into place. Throughout the language-oriented chapters, Black always refers back to concepts within Rails, often in ActiveRecord, using what has just been learned to explain the more ‘magical’ aspects of Rails.

With the language-focused chapters out of the way, Black returns to the Rails app he began at the very beginning, and enhances it with the Ruby skills we’ve learned throughout the book. It’s here that a great deal falls into place – not just from a greater appreciation of what’s going on under the hood, but also through a new-found appreciation for Ruby idiom, and how best to work with (rather than against) Rails.

If there are faults with the book, they are few. Black consistently gives his example database schemas as SQL. Whilst I have no problem with this personally, it’s becoming more common in the Rails community to list them as database-agnostic Ruby migrations. Also, some of the code examples in the book may seem a little confusing to begin with – one early example features a lambda function, a concept not really explained until a good few hundred page later. And the initial chapter on Rails seems perhaps a little rushed, trying to cover much of the ground that many may have read in Agile Web Development with Rails.

But these are minor gripes. Ruby for Rails is an excellent guide to the Ruby language, especially for anyone coming to it afresh. It’s exactly the book that many in the Rails community have been waiting for, and it’ll improve your pure Ruby skills no-end. Certainly a book that I’ll be returning to many times in the future.


Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Get Started

0 Responses to “'Ruby for Rails' by David Black”

  1. but its growing on me more and more.. Incredible possibilities

  2. Ruby still scares me, but its growing on me more and more.. Incredible possibilities

  3. It’s a great book, but try Obie’s “The Rails Way” for a more up to date reference

  4. Hımm wery god proje thanks

  5. I think you did a great job of pointing out the major strengths and weaknesses of the book.

  6. I Think Ä°t is Very good information ….

  7. Ä°t Ä°s Very Nice Ä°nformation…

  8. ooo vry good perfect..

  9. Being something of a book junkie and relatively new to Rails, I bought essentially all the available books, and Black’s book is the one I ended up liking the most. If you know Ruby and just want to learn Rails, several other books are good, but they tended to leave me lost at places by assuming I could read all the Ruby code. Ruby for Rails does an excellent job of introducing the two topics together, making it the best intro I’ve found for someone new to both Ruby and Rails.

  10. James McCarthy on August 3, 2006 at 8:55 pm said:

    This is an excellent book. It is perfect for those who have worked through the examples in Agile… and developed a taste for rails but have not yet acquired the knowledge of ruby to cope in the wild.

    The examples are extremely clear and well thought out. I have found a lot of the concepts I struggled with in The pickaxe just fall into place when Black explains them.

    I bought the e-book when it was in beta and it became a constant companion so added the paper one as soon as it came out.

Leave a Reply

You must be logged in to post a comment.

man working on his laptop

Are you ready to start learning?

Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Start a Free Trial
woman working on her laptop