Getting Started With Ruby on Rails

Updated: July 2, 2009

There's been quite a bit of buzz recently about a new technology called Ruby on Rails that's revolutionizing web development. This article will provide a little background on Ruby on Rails, and provide some tips on how to get started using this new technology.

Ruby is a programming language originally developed in Japan. It's generally classified as a scripting language, like Perl and Python, because 1) it's an interpreted language, and 2) it's a typeless language. It's also an object-oriented language; in fact, unlike some other languages, everything, including even the simplest types, is an object.

What has really taken the development realm by storm is Rails, a framework for web development that has been implemented in Ruby. Rails enforces a well-defined structure on web sites, and then takes advantage of that structure to automate finding all of the different components of a complex web site. This allows Rails to support a very nice Model-View-Controller (MVC) implementation, with virtually none of the complex configuration required by other technologies, such as Java's Struts framework.

Even more impressive, Rails features ActiveRecord, a component that provides object-relational mapping capabilities for the framework. With ActiveRecord, developers relate models (objects) to database tables, and also define the relationships between models. ActiveRecord then automates all functionality for retrieving data from the database, searching based on various criteria, database updates, etc.

Now, object-relational mapping isn't new. For example, Hibernate is a powerful object-relational mapping technology that's available for Java. But Hibernate requires extensive configuration, while ActiveRecord eliminates the majority of configuration by interrogating the database automatically to retrieve required information, such as the names of the columns in a table. The end result is that ActiveRecord eliminates most of drudgery involved in interacting with a database.

So, what's the easiest way to begin learning Ruby on Rails? It comes down to to three things:

  • Documentation
  • Tools

Documentation

To get started with Ruby on Rails, the first thing you need to do is buy the Ruby on Rails bible, which is a thick book called Agile Web Development With Rails, by SamRuby, Dave Thomas and David Heinemeier Hansson (now in its third edition). This book contains everything that you need to know about this exciting framework. It begins by guiding the reader through the development of a fairly sophisticated web application, before delving much deeper in later chapters.

Make sure that you buy the third edition. Even though Rails is relatively new, the sheer pace of development surrounding Rails has necessitated a second edition barely a year after the first one came out (and a third edition two years after that).

Tools

There are a variety of free tools that can assist you in developing Rails applications:

  • Instant Rails (Windows only)
  • Aptana Studio
  • NetBeans
  • TextMate (Mac only)

InstantRails

InstantRails is a pre-packaged development environment for Ruby on Rails (for the PC only, however). It contains Ruby on Rails, MySQL, Apache 2.x, Mongrel and PHPMyAdmin. All of the elements are already configured, so all you have to do is get the InstantRails download, unzip it in a folder and run it.

InstantRails provides a handy control panel, which is shown below. Using the control panel, users can manage web applications, launch PHPMyAdmin, launch a Ruby console window, etc.

Within the InstantRails package, Apache functions as the web server. Mongrel is a connector, a component that allows Apache to interact with Ruby. MySQL is a fully configured relational database system that can be used in Rails applications. To make database-related activities easy, PHPMyAdmin is provided; this easy-to-use tool provides extensive functionality for managing mySQL databases.

To download InstantRails, use the link below. InstantRails is hosted by RubyForge.org, which is also a good place to look for other Ruby-related and Rails-related software packages.

A Few Caveats: Be aware that InstantRails is currently only available as a Windows download. Additionally, since it consists of a bunch of bundled components, it tends to lag behind Rails itself in terms of new versions comoing out. However, it's a good tool for learning Ruby on Rails.

Aptana Studio

Aptana Studio is a free, stand-alone IDE built on top of the Eclipse codebase, with customized support for Ruby on Rails. For those who might be unfamiliar with it, Eclipse is a modular integrated development environment (IDE) available from the open source community. It was originally started as a Java-centric tool, but its modular nature has encouraged the open source community to create 1) a wide variety of plug-ins for it, and 2) whole new applications, such as Aptana Studio, built on top of the Eclipse components.

To set up Aptana Studio, download the software from the web site. Unzip the download in a folder and you're good to go. However, a plugin is required in order to add the suport for Rails. Run the application. When it comes up, select "Software Updates" from the "Help" menu. Then select "Find and install...". This will bring up a list of plugins available for installation, one of which is called "RadRails". You'll need to install that plugin. Aptana Studio works on both Windows machines and Macs.

Aptana Studio can be downloaded at the link below:

Aptana Studio includes apabilities for running Webrick or Mongrel web servers to field your web application. Aptana Studio is what I'm currently using. Aptana Studio or NetBeans are also both excellent choices for Java developers moving into the Ruby realm.

NetBeans

NetBeans is another open source IDE, like Aptana Studio. The two are very comparable in features. NetBeans also works almost every viable development platform available, including Mac, PC, Linux, etc. It autmatically comes with support for Java, Ruby, Rails, etc., with no requirement for any plugins. Like Apatana Studio, it also includes features for managing web server instances.

NetBeans can be downloaded from:

TextMate

TextMate is a text editor avilable for the Mac. There are feature "bundles" available that make it Rails-aware, e.g. - by providing features such as Ruby syntax highlighting. There are a lot of people in the Rails community who love TextMate. My sense is that it provides a great deal of power in a minimalistic package, but has a fair learning curve. TextMate is not free, although the price is reasonable and well within reach for most people.

Next Steps

Armed with the definitive Ruby on Rails textbook and various tools, developers should have everything that they need to take Ruby on Rails for an extensive test drive. The next step is to build some small applications and discover how much time Rails can save when it comes to building web applications.



Comments

No comments yet. Be the first.



Leave a Comment

Comments are moderated and will not appear on the site until reviewed.

(not displayed)