ow! In a word, that was my first reaction to developing my first Web application using Ruby on Rails. This third of a series of articles on Ruby guides you through an exploration of the Ruby Web application framework called Rails, more formally, Ruby on Rails. If Ruby the programming language didn’t move your internal excitement meter, perhaps Ruby on Rails will. In the paragraphs to follow, you will develop the first part of a small, but complete, Web application in just one line of code! Don’t believe me? Read on and give it a try. Ruby is a metaprogramming language. Metaprogramming is a means of writing software programs that write or manipulate other programs thereby making coding faster and more reliable. The power of this technique shines through Rails and may give you a sense of the productivity gains offered through Ruby.
Setting up Ruby on Rails
In order to develop and run Web applications using Ruby on Rails, you will need Ruby. Ruby installation instructions were covered in Part 1 of this series. Once Ruby is installed, Ruby on Rails is most easily obtained through RubyGems. RubyGems is a Ruby package manager similar to package managers that you might have seen or usedlike rpm, apt-get, and emerge. More information on RubyGems is available here. However, the Ruby on Rails download page, includes a link to get RubyGems and then you can use RubyGems to obtain Rails. In this article, I downloaded RubyGems version 0.8.11 offered from the Ruby on Rails Web site. Per the instructions, I simply downloaded the RubyGems zip file, extracted the zip file contents into my Ruby folder, and then ran the following Ruby script from the gems directory to install RubyGems:
C:\ruby\rubygems-0.8.11> ruby setup.rb
With Gems installed, getting and installing Rails is a snap. Simply request Gems install Rails and all dependency packages as shown below:
C:\ruby\rubygems-0.8.11> gem install rails --include-dependencies
Depending on the size and speed of your system and Internet connection, it will take a minute or two to get you up and running with Ruby on Rails using RubyGems. Using the same Gems command, you can also request Rails (or other Ruby package) updates as they come out too.
If you do not feel like using RubyGems, a standalone package of Ruby on Rails is available from the download site as well. Furthermore, for those on Windows platforms that want to get everything they need in one convenient download, a new download site has been setup for getting everything you need for Rails development with a single click. The Instant Rails Web site offers Ruby, Rails, Apache Web server, and MySQL database in a single "all preconfigured" download. This download allows you to unzip everything into a directory and run it. As it is already preconfigured, it does not require you to modify any environment variables or otherwise modify your system.