Review: RailsSpace hits the Ruby on Rails learning sweet spot
It may be trendy, but Ruby on Rails (RoR) is also still relatively new -- which means it's not as easy to find resources to learn it as it is for, say, Java or Struts. The publishing industry has geared up at last, though, and there are now several dozen options for those of us trying to teach ourselves. RailsSpace: Building a Social Networking Website With Ruby on Rails (Addison Wesley Professional, 2007) is a welcome addition to the list.
Authors Michael Hartl and Aurelius Prochazka are unabashed fans. They speak more than once about Rails "magic" and tout Rails for making tedious, repetitive Web development tasks "trivially easy." If you buy into the premise that Ruby on Rails is a great productivity booster that can make once-dreary coding tasks fairly painless (which I do), RailsSpace offers a lot of hands-on, practical examples of how to use Rails intelligently. However, the book's style might not be fully appreciated by those in the "What's this all about, anyway?" phase or those who are still skeptical about RoR.
The book takes readers through building a MySpace-type Web application, also titled "RailsSpace," step by step. Hartl and Prochazka start with basics such as creating and registering users, and they work up to more advanced features such as letting each user find, invite and accept friends to build a social network. While I'm not planning to create a MySpace knock-off anytime soon, and I suspect most other readers aren't either, much of the information is transferable to building other types of applications. For example, this social networking site deals with creating secure log-ins, allowing users to update their information, displaying user profiles, adding comments to some content and sending e-mail through Rails.
I was particularly happy to see a full chapter devoted to "searching and browsing." This is a topic that's given surprisingly short shrift in some other Rails books. RailsSpace's authors go beyond the RoR "find_by_attribute" methods that let you pluck items out of a database according to criteria in specific columns. They give an explanation of a full-text search plug-in called Ferret, as well as show how to implement a location-based search to find all users located within x miles of a given ZIP code.
RailsSpace is quite readable while it educates. The authors maintain a fairly light, breezy style even when talking about complex code. This didn't make it any less challenging when trying to wrap my head around new (for me) concepts like REST (Representational State Transfer, a way of using Web protocols in object-oriented programming), but it did make the efforts less painful.
In each of the sections, the authors explain when and how using Rails conventions can help give an application increased functionality with streamlined code. For instance:
"We would like to be able to impose restrictions on the kind of user objects we save to the database; for instance, we probably want to limit the length of screen names and passwords -- say, at least four characters long but no more than 40. We would also like to make sure that screen names and e-mail addresses are unique. Finally, we'd like to make sure that there is a nonempty e-mail address which is at most (say) 50 characters long. Rails makes it easy to impose these sorts of constraints on our models by applying validations before anything gets saved to the database:
Class User < ActiveRecord::Base
validates_uniqueness_of :screenname, :email
validates length_of :screen_name, :within = > 4..20
validates_length_of :password :within = > 4..40
validates_length_of :email, :maximum = > 50
validates_presence_of :email
end
"... Rails runs these validations when it tries to save the user to the database, and the save only succeeds if all the validations pass. If any validation fails, it gives an error message, which can be returned to the user."
Ruby on Rails
Additional Resources



White Papers & Webcasts
Extend, Replace, or Convert; which is the best way forward for COBOL Applications?
Download this white paper, free, compliments of Micro Focus!
Data in Action: Making the Planet Smarter
Register Now
Oracle Accelerate - Not Just Smart but Timely
Download Now!
Why BI is Ripe - Now! - For Businesses of Any Size
Download Now!
The Workday User Experience Video
Watch Workday's Creative Director, Scott Lietzke, discuss the business-centered design philosophy at Workday.
Business Process Framework Demo
Learn about Configurable Business Processes and Calculated Fields. Watch Now!
Rapid Implementation: The New Age of ERP
Download Now!
Manager Experience Demo
Go beyond self-service solutions to perform more effectively. Watch Now.

