Completing and Verifying the Rails setup

We are just a few simple steps away from completing the setup of our development environment and verifying its functionality.  Then we'll create an online collaborative cookbook for holding and sharing everyone's favorite recipes. We want our cookbook to:

There's a working version of this application included in the Instant Rails download and we'll use it to verify the functionality of our development environment by seeing this application in action.

Step 1.  Configure Instant Rails' paths

The various components of our development environment need to 'know about each other."  Instant Rails takes care of this for you the first time you start the application.  

Browse to the InstantRails directory and double click on InstantRails.exe.

 The dialog box shown in Figure 3 will appear.  

Click 'OK'.

Instant Rails path configuration
Figure 3. Completing the configuration

When Instant Rails has completed the configuration, the main application window will appear showing that the configuration files for Apache and mySQL have been updated and both servers have been started.

Instant Rails main window
Figure 4.  Instant Rails main application window

Step 2.  Let Windows know...

Next, we need to modify the Windows Hosts File so that Windows knows where to find our application.  To do this, 

click on the 'I' button in the Instant Rails main application window (next to the 'Apache' button) and follow the menus as shown in Figure 5.

Modify Windows Host file
Figure 5.  Modifying the Windows Hosts file

The Windows Hosts file will be opened in Notepad.  Make sure the line "    localhost" appears in the file.  If it doesn't, add it to the end of the file as shown in Figure 6.  This tells Windows to search locally for the web site.  

When you're finished, save the file if you've made changes and exit Notepad.

Updating the Windows Hosts file
Figure 6.  Modifying the Windows Hosts file

Step 3.  Edit and Copy the batch file that let's us use Ruby

Open the C:\InstantRails\use_ruby.cmd file with your text editor.  Add "C:\InstantRails\ruby\lib;" to the PATH as shown in Figure 7 below.  Save the file.  

Important note:  Remember that the name of the Instant Rails root directory on your system will probably not actually be "C:\InstantRails".  Instead, it will be "C:\InstantRails-1.0" or "C:\InstantRails-7.6" or something else, depending on the name of the release you're working with.  Make sure that what you add to the PATH per the instruction above is named appropriately for your situation.  Let us know if this causes too much confusion for you.

Now use "Save As" to put a copy in the C:\WINNT\system32 directory so it's there, and therefore in the PATH, the next time you open a Command Prompt window. 

Another Important note:  Saving the file to the second location isn't absolutely required, but doing so will save you  keystrokes every time you restart your development environment.  One alternative is to just manually change directories from where ever you start (controlled by the "Start in" property for your Command Prompt window) to the "rails_apps" directory from whence most all of your Instant Rails work will begin.  If you DO decide to use this time-saving device, make you save the file to the appropriate location, which is whatever the "Start in" property for your Command Prompt window is set to.  For XP users, for example, the system32 directory is normally located under "C:\Windows\", not "C:\WINNT\" so they should "Save As" to the "C:\Windows\system32" directory.  If you've installed Instant Rails on a system at work, your admin may have your Command Prompt window set up to "Start in" some network drive.  Use whatever location makes sense based on your settings and your ability to control them.  Let us know if this causes you too much confusion.

Figure 7.  Edit the use_ruby.cmd file

Step 4.  Use Ruby

Open a Command Prompt window and enter >use_ruby  The result is shown in Figure 8 below.

Use Ruby
Figure 8.  We're going to use WEBrick so we need to start Ruby

Step 5.  Stop the Apache web server

Bring up the InstantRails main application window (if you minimized it, it's the 'I' icon in the system tray on the bottom right of your screen).  Once you have it open, stop the Apache web server using the menus as show in Figure 9 below.

Stop the Apache server
Figure 9  Stop the Apache server

Step 6.  Tell Instant Rails which app we're going to run and start the WEBrick server

We have to tell Instant Rails which app we're going to run.

Bring up the main application window and navigate the menus as shown in Figure 10 below.

 Starting SCGI
Figure 10  Last step to configuring your application

You'll be presented with the window shown in Figure 11 below.  

Select the cookbook application, then click the "Start with WEBrick" button.  

Starting SCGI for your app
Figure 11  Tell Rails which app you're going to run and start the WEBrick server

When  you click the "Start with WEBrick" button, Instant Rails will launch a new Command Prompt window and start the WEBrick server.  You can move on to the next step once you see the line containing "WEBrick::HTTPServer#start" as shown in Figure 12 below.

Figure 12.  WEBrick is now ready to serve your browser needs

Step 7. Verify the configuration

Open your browser and point it to "http://localhost:3000/recipe/list".  

You should be rewarded with the result shown in Figure 13 below.

Success at last
Figure 13.  Success at last !!!

Step 8.  Stop WEBrick

WEBrick can only serve one 'web site' at a time.  To get ready to begin development on another app, we need to stop the server at this point. 

Bring the Command Prompt window in which you started WEBrick into focus and enter Ctrl-C.  

This should stop the server.  It may close the window.  If not, or if you'd rather, just close the window until you need to restart WEBrick to see the results of your development efforts that follow.