- Featured Columnists
Table of Contents
- Web Basics
- Publishing on the Web: Putting Files on the Server
- Web Design Process and Workflow
- Project Management
- Mark My WWWord: HTML and XHTML
- Standards Compliance
- Meta Tags and Search
- Enhancing Web Page Interaction
- Web Graphics
- Web Page Optimization
- Overview of Servers
- Server Programming Basics
- Careers in Web Design
- Intellectual Property for Web Designers
Ruby on Rails, the New Jewel in Web Development
Last updated Oct 17, 2003.
By Meryl Evans
Contrary to its name, Ruby on Rails, also called RoR or Rails, has nothing to do with precious stones or trains. Ruby without the Rails is an open source (read free) object-oriented programming language like PHP, Perl, and Python. Rails is operating systems independent, so it works with Linux, Windows 95/98/2000/NT/XP, many types of UNIX, DOS, Mac OS, BeOS, and OS/2 operating systems.
Yukihiro Matsumoto created Ruby in 1993. In 2004, David Heinemeier Hannson of 37signals (http://www.37signals.com) conceived Rails when he developed Basecamp, a Web-based project management application. Hannson's programming experience was limited to five years of PHP and he didn't claim to be a developer, which says something for Rails' simplicity.
Ruby's two principles are "don't repeat yourself" (DRY—yes, another acronym with more to come) and "convention over configuration." This process keeps code small and lean, so there are fewer lines of code. "Convention over configuration" means that Rails doesn't use configuration files. Instead, most Rails-focused resources say that Rails uses programming conventions that magically make things work. As unbelievable as this sounds, the point is that programmers struggle less to get the application to do what it is supposed to do.
For example, a Rails-based application has a hierarchy of specific folders and when the correctly named items are put in the right folders, Rails automatically knows what to do. Explaining this goes beyond the scope of this article, but Rails Goes Where explains this. RubyStyleGuide (http://www.rubygarden.org/ruby?RubyStyleGuide) has a list of these standards that can do magic. A loose analogy of this is when opening a folder loaded with pictures, Windows "knows" to use thumbnail images instead of a list of files.
Its syntax includes a mix of Perl and Ada with similar or borrowed concepts from Python, Lisp (name comes from linked processing), Dylan (name comes from one of the volunteers involved with Dylan's creation), and CLU (old language that introduced important ideas for using iteration through objects, a step in the direction of object-oriented programming)—all of which are programming languages. These characteristics help Ruby create compact, readable, easy to maintain, and simple applications.
Rails is the Web application framework for Ruby. When programmers write code, they work to create reusable code. These components of reusable code make up the application's framework. A well-built framework like Rails makes development easier when it comes to adding and modifying the application. Rails has many libraries of code for completing common tasks such as form validation, cooking management, and client-side operations using Ajax.
If you're familiar with PHP, then you know it's a programming language. Then there is PEAR (PHP Extension and Application Repository), a framework and distribution system that contains reusable PHP components. It's also a standard style for PHP written code just like Rails is for Ruby. Another programming language, Python, uses Zope for its framework.
In Rails, the Active Record, which connects business objects and relational database tables, represents the model. The view is created through the use of Rails templates for .rhtml files that use HTML with Ruby code. Action Pack handles the controller by routing requests through the controller with one method for every action.
Before you download Ruby and get going with Ruby on Rails, it requires using a host that provides Rails support. Just like ColdFusion, PHP, and .NET, Ruby on Rails can't operate without a Rails-based host. Why can't you do it yourself by adding a module or something along those lines? To get quality and fast server performance requires the host to support FastCGI (also known as FCGI). FCGI is a high-performing extension to CGI without service specific application program interface (API) limitations. Furthermore, it most likely can't be installed when using a typical shred host.
David Heinemeier Hansson, creator of Rails, says, "It's possible to run Rails on Apache as CGI, but it's slow. It's also possible to run your own Web server (called webrick) if the host allows you to use other than port 80 Web servers. But FCGI is where it's at. It's probably easier to move to a new host than to make a host change its ways." Web hosts currently with Ruby on Rails support are listed on the RoR wiki.
Source releases for all platforms lists the latest stable release version as well as the preview releases. The downloads from this site work with Linux, many types of UNIX, DOS, MacOS, BeOS, and OS/2 operating systems.
Windows Ruby installer is a self-contained installer that comes with Ruby, a handful of extensions and packages, a syntax-highlighting editor, an execution environment, and a help file that contains the full text of Programming Ruby: The Programmatic Programmer's Guide. If you're using Windows, this is a good way to go.
Ruby for OS X provides information on how to download and install Ruby on Macs.
In the short period that Rails has been around, many sites have hit the Internet with introductions, tips, tricks, tutorials, and libraries related to RoR.
Ruby on Rails Official Web site. The official Web site has the Rails installer, documentation, weblog, resources, and source code info.
Ruby language official Web site. The official Web site for the language itself that includes Ruby info, files, documentation, a community, and development resources.
Installation How-tos. Documentation on how to get started with Rails and how to install and set it up.
Why's (poignant) guide to Ruby. Not your typical guide as it has funny cartoons and stories. It's as much a humorous book as it is a guide to Ruby.
Programming Ruby. An online book that's no different from a book you'd get from the bookstore. It starts at the beginning talking about Ruby and how to get it, and then works its way through its roadmap, classes, objects, and variables.
Four Days on Rails (pdf file). The document contradicts the claims that Ruby on Rails is easy to use and works to fill the gap for the lack of a roadmap in the many online RoR resources.
Rails mailing list. Mailing lists often have great and insightful discussions surrounding their topics. The Rails list is no different.
Rolling with Ruby on Rails is a good place to start experimenting with Ruby on Rails. It begins with installing Ruby, Rails, and the MySQL database. The tutorial creates an online collaborative cookbook.
InformIT Articles and Sample Chapters
This article is written by the creator of the language. He explains why Ruby is better than Perl and Python.
Pete McBreen has an article series covering Ruby for the Nuby.
Sample chapter excerpt from Sams Teach Yourself Ruby in 21 Days shows how to use containers to contain your objects in strings, hashes, and rangers.
Books and e-Books
Agile Web Development with Rails (The Facets of Ruby Series) by Dave Thomas and David Heinemeier Hansson (Pragmatic Bookshelf, 2005, ISBN: 097669400X). You can't beat a book from the feller behind Rails.
Ruby in a Nutshell by Yukhiro Matsumoto (O'Reilly, 2001, ISBN: 0596002149). This book by the creator of Ruby is more of a reference.
The Ruby Way by Hal Fulton (Sams, 2001, ISBN: 0672320835). This book is for readers already familiar with Ruby. It contains code samples to show the reader how to use the programming language.
Programming Ruby: The Pragmatic Programmers' Guide, Second Edition by Dave Thomas, Chad Fowler, and Andy Hunt (Programatic Bookshelf, 2004, ISBN: 0974514055). This doorstop—at over 800 pages—offers a starting place for those new to the language.
Sams Teach Yourself Ruby in 21 Days by Mark Slagell (Sams, 2002, ISBN: 0672322528). The book introduces the reader to Ruby and assumes the reader has familiarity with programming languages.