"Ruby on Rails: Up and Running," by Bruce A. Tate and Curt Hibbs

Pros: Concise, Clear, Well Organized
Cons: Insufficient
Rating: 2 out of 5

“Ruby on Rails: Up and Running,” is an overview of the Rails web development framework. There is a caveat up front that the book is not intended to replace the reference manual or google search. The goal is to get developers unfamiliar with the framework started quickly. I might rewrite that statement as, “This book will provide you enough information to decide you want to use Rails, but not enough to actually do so.”

The challenge of a book like this is in deciding what to leave out. (And if you think that it’s easy, give it a try.) Done right, this kind of book is like a roadmap to a larger subject. Done wrong, it’s frustratingly incomplete, as though the meat of the discussion has been elided in favor of a brief comment on the side of the page: “I have a truly marvelous demonstration of this proposition which this margin is too narrow to contain.” This is my gripe – the book reads as though the authors died tragically in a duel just a day or two before they’d planned to finish revising the manuscript.

Many of the concepts in the book are conveyed by examples. Good examples are wonderful for communicating about software, but they either need to stand on their own, self-explanatory and complete, or should be accompanied by some instructive text. In too many cases, they were neither.

For example, the section on schema migrations shows an example of creating a database. The great thing about migrations is the ability to move back and forth between various versions of the database schema automatically. However, there’s no explanation of what command and arguments to use to go back to a prior version of the database schema. Given that this is the benefit of the feature, it’s a strange omission.

Similarly, the book used a few examples to explain validation: validates_presence_of, validates_format_of, and validations_length_of. The section even notes that there are several kinds of validation — without giving a list of the options available. I would cheerfully have foregone the half page screenshot of Rails’ web documentation on page 14 – yes, I know what API documentation looks like in a browser window, thank you – to have a half page table of available validation options on page 35.

Generally my dissatisfaction is with the omissions; the content that’s present in the book is good. Only one error stood out enough to catch my eye, and it was a minor point in a footnote. The author noted the necessity of properly escaping HTML output. This is true, as it prevents attackers from inserting HTML into text rendered by the web site. This helps prevent cross site scripting attacks, among other things. The footnote, however, explains that this is to prevent SQL injection attacks. An SQL injection attack uses bogus input, such as to a web form, to force the database to run a query desired by the attacker. I don’t follow the author’s reasoning that escaping HTML characters in the output to a user’s browser will prevent an attack delivered as input to the database.

The latter chapters of the book did improve. The chapters on views and AJAX were more satisfying and seemed more complete than those on active records, but overall, I just didn’t get enough out of this book. I understand the goal was to create a short book to quickly get people up and running, not a complete reference. Yet, when I started working on my own project with Rails, I found it was other books and online references that I used to get up and running. The book was enough to convince me that I wanted to give Rails a try, but for the cost of a technical book, that’s not enough.

Posted in Reviews
One comment on “"Ruby on Rails: Up and Running," by Bruce A. Tate and Curt Hibbs
  1. Jimmy says:

    I like this book because it is short, thin, and to the point. It gives me just enough information to get started. The examples worked fine until I tried the drag & drop one.

    This is probably not the place to ask a question like this. But, please let me…

    The error from drag & drop operation:

    Processing SlideshowsController#add_photo (for 10.71.1.169 at 2007-10-10 14:44:43) [POST]
    Session ID: 253902577ac03cf8a5c6393c3721dade
    Parameters: {“action”=>”add_photo”, “id”=>”photo_3”, “controller”=>”slideshows”}
    SQL (0.002208)  SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
    FROM pg_attribute a LEFT JOIN pg_attrdef d
    ON a.attrelid = d.adrelid AND a.attnum = d.adnum
    WHERE a.attrelid = ‘slides’::regclass
    AND a.attnum > 0 AND NOT a.attisdropped
    ORDER BY a.attnum
    
    SQL (0.000436) BEGIN
    Slide Load (0.000000) RuntimeError: ERROR C42804 Margument of WHERE must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1
    SQL (0.000429) ROLLBACK

    ActiveRecord::StatementInvalid (RuntimeError: ERROR C42804 Margument of WHERE must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1):
    ……..

    Based on the above error, the problem seems to be with the generated select statement.

    SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1)

    Instead, it should be:

    SELECT * FROM slides WHERE (slideshow_id = 3) ORDER BY position DESC LIMIT 1)

    I also tried the following:

    >> slide = Slide.find 1
    >> slideshow = slide.slideshow
    >> slideshow.slides.first.move_to_bottom
    ActiveRecord::StatementInvalid: RuntimeError: ERROR C42804 Margument of AND must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: UPDATE slides SET position = (position – 1) WHERE (slideshow_id AND position > 1)

    Same kind of problem. The update statement should be like:

    UPDATE slides SET position = (position – 1) WHERE (slideshow_id = 3 AND position > 1)

    I am not sure how to correct this problem. I understand that you finished this book more than 10 months ago, if you still have the example in your computer somewhere, please help. Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Stuff for Gamers

Take a look at the shirts-n-things in our stuff for gamers store.

Archives