Ruby on Rails Enterprise Application Development
by Elliot Smith and Rob Nichols.
Packt Publishing, Birmington 2007.
[Full disclosure: I have received a copy of the book in exchange for this review.]
The book targets Rails beginners that have a little prior knowledge of Ruby and Ruby on Rails and aims to accompany them on their way to Rails mastership. It focuses on the iterative and stepwise development of a small CRM system for a small company. Since the chapters don’t anticipate, it can be read straight forward, while the reader continuously learns and refines his skills.
It starts with a general introduction on why to use a web-based client-server architecture for business applications, and then recommends Rails to implement them, last but not the least because it is open source and enables easy testing.
Next, the reader is introduced to basic database design, elementary normalization and how Rails’ ORM works. Then, it discusses Rails naming conventions and includes a list of reserved words in Ruby. A list of reserved class names is unfortunately not included, it would have been very helpful since Ruby already claims some very generic class names (Date, Thread, etc.).
Contradictory to the introduction, now nevertheless follows a tutorial on how to setup and install Rails. The book was written before Rails 2 and generally speaks of outdated versions, however, most of the content is not affected by this—still, there may be some traps if one tries to follow it with more recent Rails versions. After setting up Rails, the installation of a database (MySQL throughout the book) and a revision control system (Subversion) is explained.
After these preliminaries, a Rails project is created and the book explains the Rails directory structure. Tables are set up, migrations introduced, and the reader learns about the essential ActiveRecord API with finds and relationships. Validations are addressed as well; the regular expression for email checking is broken. After a quick overview of unit testing and Test::Unit (TDD is discussed but not used), the reader can check in the code for the first time.
Now, they generate controllers, introduce ERB and pagination (using
paginate), how to do links and layout and furthermore
how to use partials and flash. The chapter also shows how to write
The application is ready for a first deployment. After an overview of the typical Rails hardware requirements, the book explains how to set up Mongrel.
The next chapter focuses on user experience. The authors introduce routes for better bookmarking, show how to add search and input validation and finally give examples of using AJAX for autocompletion. They also point out that AJAX should be used sparingly and only when it makes sense. The chapter also makes an excursion on how to setup Instiki as a help system.
After this, the book deals with improving error handling,
authentication (for which they use unsalted password hashing) and file
uploads. After displaying a primitive version of file uploads, it is
shown how to install plugins and how to use
Then, more serious deployment gets addressed. They introduce Capistrano, explain how to set it up and then use it for upgrading, downgrading and database-related tasks. A list of common problems is provided to help fix likely issues. The authors also explain how to install automatic start-up scripts, session cleaning and log rotation. The rest of the chapter deals with optimizing the Rails application: how to find and identify the bottlenecks with profiling and how to speed up Rails with the different kinds of caching available or by using eager loading. Finally, they also address scaling by using multiple Mongrels and Apache as a reverse proxy and static file server.
The last chapter, “Down the Track” tries to school the reader when it’s okay to break Rails’ conventions. They give situations where the use of custom SQL or using multiple databases is required or advantageous. The chapter also outlines general virtues of a business application developer, such as the importance of understanding the business processes, that successful applications primarily need to yield profit, that automation is good, and reporting important.
The book is concluded by an appendix showing how to setup your own Gem server.
Conclusion: The book does not satisfy the introductory claims: it is often too detailed on the basics and too shallow on the crucial things and sidetracks the reader into unimportant issues. The writing is occasionally clumsy and sometimes overuses the passive voice to incomprehensibility. Some code examples are syntactically invalid and a few Ruby-related commentary plainly wrong. Throughout the text, replace all occurrences of “property” by “attribute” and of “ampersand” by “commercial at”. Various other mistakes sprinkle the book, occasional typos, random font changes and weird spacing suggest the book was produced in a hurry. People with typographic sense will be shocked by the table of contents and complete and the utter lack of typographical quotes. The few illustrations are reproduced in a very low resolution.
Still, the book may be useful for Rails beginners that are interested in the development of an “enterprise application” and would like to know what else there is to keep track of. The complete Rails newbie however will stumble due to the preknowledge of Ruby, whilst the slightly advanced Rails developer will hardly learn anything new and would be better off with specific books on deployment or system administration to extend his knowledge.
Rating: 3 of 5 points.
NP: Minutemen—Love Dance