Getting Started with Instant Rails

Instant Rails is a single-install environment for Windows that includes the parts you need to get started building Rails applications. Installing it is trivial. Get the latest version from http://instantrails.rubyforge.org/wiki/wiki.pl and unzip the file wherever you’d like it to go. There is no real install program.

Once you’ve unzipped Instant Rails, you can start to develop your Rails application by opening InstantRails.exe. You’ll see the basic screen shown in Figure 1-6.

The main Instant Rails screen

Figure 1-6. The main Instant Rails screen

Warning

If you’re running Windows Vista, you may get a warning that “The publisher could not be verified.” If you want to run Instant Rails, you’ll need to click the Run button. (To turn off the warning, uncheck the “Always ask before opening this file” box.)

You may also get a warning about Apache or Ruby also being blocked from accepting incoming network requests. You’ll have to unblock those, too.

To create a new application, click on the “I” button to the left of the Apache button, and choose Rails Applications and then Manage Rails Applications…. You’ll see Figure 1-7, the dialog for managing Rails applications, appear.

To create a new Rails application (beyond the samples that come with Instant Rails), click on the Create New Rails App… button at the lower left of Figure 1-7. You might expect to get a dialog box, but surprise! You’ll get something like Figure 1-8.

The Rails Applications dialog, where you can start and stop applications, as well as create new ones

Figure 1-7. The Rails Applications dialog, where you can start and stop applications, as well as create new ones

A configured command-line environment

Figure 1-8. A configured command-line environment

To create a new Rails application here, just type rails hello at the command line. As you’ll see in the next section, Rails will let you know it’s created a lot of files.

To actually start the application, you’ll need to go back to the Rails Applications dialog, click Refresh List, and then check your hello application as shown in Figure 1-9.

Selecting your new application before starting it

Figure 1-9. Selecting your new application before starting it

If you click on Start with Mongrel, another command-line window will open, and the Mongrel web server will start running on port 3000. To see what it’s running, open a web browser and visit http://localhost:3000/. You’ll see the advice given in Figure 1-10.

From here, you can proceed with customizing the hello project so that it actually does something. Most of your work will be in the text editor or IDE of your choice, along with the command line. To get to the command line to work more with Rails, you’ll want to click the “I” on the main Instant Rails dialog box again, and choose Rails Applications and Open Ruby Console Window. To get to the files in your applications, choose Rails Applications and Open Windows Explorer.

Warning

You can’t just open a normal command-prompt window, since Instant Rails’ all-in-one approach leaves the normal “DOS box” knowing nothing about Rails. Any time that you want to connect with your Ruby application from the command line, you must go through Instant Rails’ Open Ruby Console Window button.

The Rails welcome page

Figure 1-10. The Rails welcome page

You can upgrade gem-based components within Instant Rails using gem install rails at its command line. For more detailed information on upgrading the version of Rails inside Instant Rails to the current version, visit http://excursionsonrails.com/.

Get Learning Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.