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."



- Excel 2010 Cheat Sheet
- Register for this Computerworld Insider Cheat Sheet and gain access to hundreds of premium content articles, guides, product reviews and more.
- The Keys to Distributed & Agile Application Development
- How leading firms are winning with strategies for efficient application development, without relying on co-location.
- Overcome Top 7 Admin Challenges of Active Directory
- As Active Directory's role in the enterprise has drastically increased, so has the need to secure the data. Gain insight on creating repeatable,...
- Insiders Can Ruin Your Company. Take Action.
- Did you know that 80 percent of threats to an organization come from the inside? The threat from insiders is often overlooked in...
- Top Solutions and Tools to Prevent Devastating Malware
- Custom malware frequently goes undetected. According to Forrester Research, the best way to reduce risk of breach is to deploy file integrity monitoring...
- Streamline Compliance and Increase ROI
- Streamline, simplify, and automate compliance related activities; especially those that impact multiple business units. This white paper from NetIQ, outlines solutions that will... All App Development White Papers
- Reduced TCO for Communications Applications with New Oracle SPARC Servers
- In this webcast learn how Oracle's new SPARC T4 servers and SPARC Supercluster deliver the security, performance, and scalability required for 4G network...
- Optimizing Networks for the Cloud
- Join guest speaker, Rohit Mehra, IDC Director of Enterprise Communications Infrastructure, to explore current trends, discuss best practices for optimizing Data Center and...
- Apps QuickStart Series Part 2: Designing and Deploying SQL Server on VMware vSphere
- Download this webcast to learn about the design considerations for virtualizing SQL workloads, performance and scalability information and high-availability options, as well as...
- Apps QuickStart Series Part 1: Designing and Deploying Exchange 2010 on VMware vSphere
- Download this webcast to learn the virtual hardware design considerations for Exchange 2010, deployment using the building block approach, options for high-availability and...
- Customer Spotlight: How IPC The Hospitalist Company Implemented Oracle on VMware
- Have you been looking to hear about customer's experiences with the new VMware vCenter Site Recovery Manager product? View this webcast to learn... All App Development Webcasts