Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×

Ruby For Rails 173

Simon P. Chappell writes "This may not be the book that you think it is, if you don't read the title carefully, but it is the book you need, if you are developing applications for Ruby On Rails (often known as just Rails, or RoR, to its friends). When learning any new development platform, there are many idioms and approaches, best practices if you will, that can benefit your development efforts. This book sets out to bring you that understanding of the best way to write the Ruby side of your Rails application." Read the rest of Simon's review.
Ruby For Rails
author David A. Black
pages 493 (17 page index)
publisher Manning
rating 10/10
reviewer Simon P. Chappell
ISBN 1932394699
summary A stunningly well written explanation of real-world Ruby skills for Rails development.


I see two main audiences for this book. The first group would be those who are learning to develop Rails applications and need some help with their Ruby skills. The second group would be those who already have good Ruby chops, but who want to learn the primary Rails idioms and techniques. Naturally, there is always the curious geek crowd who might find the twofer of an introduction to writing real-world Ruby and a hype-free description of what Rails actually brings to web development, to be quite attractive. I place myself firmly in the third group, but after reading this book, I'm ready to move to the first group.

To quote it's own website, "Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern." The first thing this tells us is that like any framework worth it's salt, it is fully buzzword compliant. The second thing it tells us is that it really does try to help with every layer of your application, from providing a full controller to automatically mapping your data objects to their respective backend database tables. Oh, and with the bare minimum of configuration files to boot! For those of us who have developed web applications with Java, this is a welcome break.

The first part describes "The Ruby/Rails Landscape" and has three chapters that describe how Ruby works, how Rails works and then shows a very simple example of Ruby-enhanced Rails development.

The second part describes "Ruby Building Blocks" spanning five chapters, four through eight. This part is a very good tutorial style introduction to Ruby. Chapter four introduces objects and variables with chapter five showing how to organize those objects with the concept of classes. Chapter six introduces us to modules and program organization in general. Chapter seven talks about the default object, self, and scope. Chapter eight covers control flow techniques. This is more than just a fancy way of saying conditionals and loops, because it includes one of the better explanations of closures that I've read to date.

The third part describes "Built-in Classes and Modules", in chapters nine through thirteen. Chapter nine covers some of the Ruby language essentials for Ruby development in the trenches. These include useful syntactic sugar, the family of methods that change data "in place" rather than returning a modified copy, some of the tricky aspects of the Boolean objects and the proper ways to compare two objects so that you get a comparison on their contents, which is likely to be what you want, rather than their memory location. Chapter ten looks at scalar objects: strings, symbols, numbers, times and dates. Chapter eleven examines the Ruby collections: arrays and hashes and discusses when you would use each one, based on their relative strengths. Chapter twelve looks at the regular-expression facilities within Ruby and chapter thirteen wraps up our tour of Ruby with some of the dynamic aspects of the language, including the "eval" family of methods that allow a Ruby program to run arbitrary code.

The fourth and final part describes "Rails Through Ruby and Ruby Through Rails". To quote the book, the purpose of the fourth part is "helping you get more out of Rails by knowing more about Ruby." To this end the simple application created in the first part of the book is revisited and revised. Chapter fourteen starts us out with remodeling the application written back in chapter three. Chapter fifteen looks at programmatically enhancing ActiveRecord models. Chapter sixteen covers the options available for enhancing the controllers and views. Finally, the part wraps up with chapter seventeen where techniques (and much encouragement) for exploring the Rails source code are shared.

The writing is excellent and the style is very engaging. Every concept is stunning well explained. Much as I liked and enjoyed "Programming Ruby" (the "pickaxe book" to it's friends) by Thomas, Fowler and Hunt, this book takes the state of Ruby writing to a new level.

The progression of the book is very well thought out. The first part introduces us to both Ruby and Rails. You can create basic Rails applications with very little Ruby and that's exactly what this first part walks you through. Then parts two and three teach Ruby skills and idioms that are directly applicable to Rail application creation. Part four takes these new skills and shows them being applied to the second Rails application of the book. I found this to be a very good sequence for progressing through the material.

The examples in the book are excellent and many of them are geared towards Rails-style situations. This not only helps to teach Ruby skills, but also keeps the Rails context firmly front and center during the process.

The index on this book is a magnificent 17 pages. That's not something you see too often.. The art of a good index seems to be somewhat lacking these days, but this book helps to redress the balance.

If Ruby on Rails is of no interest, then this book is most likely not the one you want. Also, if you were looking for something with an exhaustive, reference-style, coverage of Ruby, perhaps you'd be better off considering something like the "Programming Ruby" book.

This is a great book, that's very easy and enjoyable to read. It's a stunningly well written explanation of real-world Ruby skills for Rails development."


You can purchase Ruby For Rails from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page
This discussion has been archived. No new comments can be posted.

Ruby For Rails

Comments Filter:
  • I'm also a type 3 (Score:5, Interesting)

    by andrewman327 ( 635952 ) on Wednesday July 12, 2006 @04:15PM (#15707992) Homepage Journal
    I have trouble learning about things when I do not understand how they work. What I like about this book is that it goes out of its way to explain how the technology works. So many programming books start with: "Now write the following code snippit in the IDE and compile." For the first time reading a /. book review, I actually want to buy this book!
  • Fad (Score:2, Interesting)

    by Umbral Blot ( 737704 ) on Wednesday July 12, 2006 @04:36PM (#15708158) Homepage
    I would invest time and money in Ruby on Rails, except that it is obviously a passing fad. This is because Rails is designed to solve a specific problem (serving web pages), and we know for sure that the serving web pages won't be a problem for all time. What people want the web to do, and how we share information over the internet, is bound to change, and when it does the Rails way of doing things will be about as useful as the Java Applet way of doing things (which was for a time The Big Thing, but now is used only in special situations). Ruby as a whole however is definitely worth learning, since it is an adaptable language, although I fear its association with Rails may kill it when Rails dies.
  • Re:Fad (Score:5, Interesting)

    by mclaincausey ( 777353 ) on Wednesday July 12, 2006 @04:47PM (#15708248) Homepage
    There's no reason to assume that Rails will fail in the near term. Rails is based on a method of decomposing software functionality that does back to the 1970s (Model-View-Controller). Rails might not be here forever, but it has a very solid architectural foundation and it is easy to adapt it to the latest trends (for instance, you can create AJAX-based Web applications very easily with RoR). In other words, the extensibility and architecure of Rails make it adaptable, just as you mention Ruby being adaptable.
  • Re:Fad (Score:2, Interesting)

    by JoeyLemur ( 10451 ) on Wednesday July 12, 2006 @04:48PM (#15708258) Homepage
    You're basically saying the web is a passing fad, then.

    And your arguement of Rails killing Ruby when it stops being the flavour-of-the-week doesn't hold much water... Perl was associated quite closely with CGI programming back in the day, and its grown beyond it.
  • I knew it! (Score:2, Interesting)

    by Mateo_LeFou ( 859634 ) on Wednesday July 12, 2006 @04:50PM (#15708278) Homepage
    I've been dodging the whole Rails gestalt, and I can't say exactly why. I watched that cute video where the guy puts together the blog in about 10 minutes, and I'm all "cool, okay". And I did that and woot!

    Then I decided to put together a blog that worked a little differently... and realized that to do so, I needed to spend a few months learning Ruby. not woot.

    Maybe I didn't stick with it long enough, but it just seems like another micromanaging "framework" to me.

  • Re:Fad (Score:2, Interesting)

    by Umbral Blot ( 737704 ) on Wednesday July 12, 2006 @04:52PM (#15708296) Homepage
    Your very wording however reveals the difference that I am driving at. Consider "the extensibility and architecure of Rails make it adaptable". This implies that one has to work to adapt Rails to new situations. You would not say the same thing about a programming language. A programming language simply is adaptable, one doesn't have to work to adapt it to new kinds of algorithems. The distinction I am making here is that you can learn something X (say Ruby) which you can apply to many tasks, or you can learn something Y (say Rails) which is suited for a particular task. Even if you can adapt Rails to do something else, that is more like learning Z (Rails 2.0) which is suited for something else. The key is one doesn't want to have to constantly chase around the latest trends, that is a good way to get burnt out.
  • Re:Right time (Score:4, Interesting)

    by tcopeland ( 32225 ) * <tom&thomasleecopeland,com> on Wednesday July 12, 2006 @05:21PM (#15708540) Homepage
    > It's about the right time for a RoR book, since
    > things have been moving so much of late,

    Yup, and this book will last for a while since it focuses on how Rails uses Ruby to do the metaprogramming "magic". So if the APIs move on slightly the techniques in Dr. Black's book still apply.

    For those who aren't on the Ruby lists, Dr. Black is a long-time Ruby user, a founder of the 501(c)(3) Ruby Central [rubycentral.org] that organizes the Ruby conferences, and generally a Rubyist from way back. He's rather a guru but he still answers questions on the mailing lists and generally does a lot of grunt work.
  • by draed ( 444221 ) on Wednesday July 12, 2006 @06:01PM (#15708795)
    yeah this is a good point. I've tried to explain Ruby on Rails to both php developers and java developers and the java developers just get it.. they completely understand the benefits and usually fall in love with it.

    On the other hand, the php developers really have a tough time grasping the concepts behind RoR. I think this is mostly because they have ever seen a MVC pattern. They are so used to mixing all their business logic in with their HTML, it's hard to comprehend the benefits of RoR and using an MVC pattern for a web app.
  • by FooBarWidget ( 556006 ) on Wednesday July 12, 2006 @06:10PM (#15708860)
    I've tried Rails. It's pretty good, but it needs to be more mature because it lacks support for the more advanced stuff. Among the things that it currently (seem) to lack are:

    - Support for saving database records using database function. In other words, I want Rails to automatically perform a query that looks like this:
    INSERT INTO foo VALUES(NOW());
    I want to insert a record that uses the database server's time instead of the web server's time.

    Or, something like this:
    INSERT INTO foo VALUES('bar', INET_HTON('127.0.0.1')); --- notice the INET_HTON() part
    In this example, I want to store IP addresses as integers in the database.

    - Apache integration is still too immature. I don't know about Apache 1, but Apache 2 integration using FastCGI doesn't work *at all*. The documentation on the website about Apache integration is very messy: different pages suggest different things. After much research I found out that:
    (1) mod_fastcgi (not FastCGI itself, which is something else!) is dead, use fcgid instead.
    (2) Integration using fcgid doesn't work either!
    After a lot more research I found a working solution: make Apache proxy requests to a lighttpd server, which is running the Rails app. This doesn't seem like an ideal situation.

    - Documentation is still too immature. While the API references are pretty good, the Wiki is very messy (see Apache integration).
  • by flipper65 ( 794710 ) on Wednesday July 12, 2006 @07:17PM (#15709220) Homepage
    Having just come off of a review of these exact frameworks for adoption at our firm I have to take exception with some of your statements. I will absolutely give you performance for all of these exceeding that of rails, however, ease of deployment (Capistrano for comparison),ease of use (have you really looked at Zope/Plone and tried to do anything really useful with it?), and, oddly enough, other than Zope, there is more documentation for rails than for either of the other two frameworks. I am including the three ruby/rails books that are currently available as rough cuts through O'Reilly's safari service.

    We settled on rails because it was faster to iterate and develop, the whole MVC design pattern just screams out to be used in database driven website design, and rails is just flat out more fun to work in than PHP ever was. Even if it turns out not to be the wave of the future, having worked in ruby using rails has already begun to teach our developers to think in terms of convention over configuration, standards and object orientation.

    Really, it's been a win for us. Also, the ruby for rails book is an outstanding read, I would also recommend enterprise integration with ruby as a good next step.

All seems condemned in the long run to approximate a state akin to Gaussian noise. -- James Martin

Working...