Playing with Ruby

If you’d like to give Ruby a go, heres a quick tutorial on how to get it up and running on your PC.

First off, you have a choice of two development environments:

  1. Instant Rails, the command line environment, or
  2. RadRails, the Eclipse based IDE (Integrated Development Environment).

1. Instant Rails

  • Instant Rails is a complete Ruby on Rails package containing Ruby, Rails, Apache, PHP, phpMyAdmin and MySQL all pre-configured and ready to run. No installer, just extract it to the directory of your choice and run it. Its all command line based, so if you want an IDE, get RadRails instead.

Installing and Configuring InstantRails

  • Extract InstantRails to D:\InstantRails or a folder of your choice.
  • Make sure there are no space characters in the folder path you chose, then run InstantRails.exe
  • Instant Rails will detect that it is being started from a new folder and ask if you want it to update the paths in configuration files. Say yes.
  • To test that it installed correctly, try running the Cookbook sample application as follows. Click on the I button and select Configure > Windows Hosts file
  • In the editor that opens up, add this line to the end of the file:
    127.0.0.1 www.mycookbook.com
  • Save the file and close the editor. This change points www.mycookbook.com to your own PC.
  • Click the I to get the main menu again and select Rails Applications > Manage Rails Applications
  • Check the checkbox beside the cookbook application
  • Click on the Start with Mongrel button
  • When the Mongrel server displays "Mongrel available at 0.0.0.0:3001", open your web browser and go to http://www.mycookbook.com/
  • You should now be running your first Rails applications.

2. RadRails, the Eclipse Based IDE

  • You will need Java J2SE v1.4.2_13 JRE or higher to run Eclipse. If you dont have a JRE installed already, get the v1.5.0 Windows Offline Installation, Multi-language
  • Ruby 1.8.5 (26MB) This is the Ruby programming language. Grab the One-click installer for Windows. This comes with the RubyGems package manager which can be useful for downloading additional packages and add-ons.
  • Rails is a Ruby development environment which allows fast development of web applications. Either download it here, or after installing Ruby, open a command window and run the command  gem install rails --remote. Answer "Y" where necessary to install all libraries.
  • RadRails is a cross-platform Rails editor built on the Eclipse IDE. You will need to install the Java JRE, Ruby, and Rails first. Then simply extract RadRails to the folder you want it in.

If you want to try to download and configure individual packages, you can get them here:

  • Eclipse SDK 3.2.1 (120MB)
  • MySQL 4.1 or 5.0
  • HeidiSQL to manage and edit MySQL databases and tables
  • XAMPP 1.5.4a is an all-in-one web server which includes Apache, MySQL, PHP, phpMyAdmin, and FileZilla along with a number of other useful packages for web development

Installing and Configuring RadRails

  • Extract RadRails to D:\RadRails or a folder of your choice
  • Run RadRails.exe from your new folder. You could also consider making a shortcut to Radrails.exe and putting it in your Start menu, your Quickstart menu, or on your Desktop for easy access
  • When you start RadRails (which is actually a well customised Eclipse) for the first time it asks you to select a workspace, this is a folder that will hold your projects. Check the "use this as default" checkbox and select a folder such as D:\InstantRails\rails_apps or D:\WebDev

Create a Ruby on Rails Application

  • In RadRails, click File > New then select Rails > Rails Project and click Next
  • Enter a project name, then click Finish
  • Click the Servers tab at the bottom of the window, select your server, then click the green triangle just above the Servers panel to start the server.
  • Now click the Globe icon (or open your web browser to http://127.0.0.1:3000/ ) and you should see a Rails welcome message.
  • Now go and learn some Ruby :)

Related Links

  • Share/Bookmark

One Response to “Playing with Ruby”

  1. Hi,

    Article looks good. Definitely useful for novice & intermediate Ruby Guys.

    Regards,
    Karthick.
    http://chennairails.blogspot.com/

Leave a Comment