Ruby In Steel :: Help Index :: SapphireSteel Software Front Page Return to the Index
Debugging Rails With Cylon
See Also

Glossary Item Box

In order to debug Rails applications using the fast Cylon debugger, you should need to use the FastTPD server. This is because the current version of Cylon is single-threaded and does not work with a multi-threaded server such as WEBrick. A multi-threaded version of Cylon is in development and will be available as a free upgrade to registered users of Ruby In Steel Developer.

First, Get Everything Installed...

The steps below explain how to install all the components required in order to run LightTPD with SCGI (which is needed in order that LightTPD can interface with Rails):

1. If you haven't got Rails installed, then the first step is to install it. From a command prompt type:
  gem install rails
 …and answer ‘Y’ to any questions about required dependencies.
2. Install the cmdparse gem:
  gem install cmdparse
3. Install the highline gem
  gem install highline

Hint: As a shortcut to running Gems, use the Gems dialog, from the Ruby menu.
install gem

In this case, you only need to enter the name of the Gem itself:
e.g. highline

Download Zed Shaw’s SCGI gem from  (at the time of writing this is version 0.4.3) and the gem file name is scgi_rails-0.4.3.gem) to a temporary directory. Change to the directory where you downloaded the scgi gem and install it. This time, you will have to do this from the command prompt rather than the Gem dialog, as you are not installing this gem from an online repository:

 gem install scgi_rails-0.4.3.gem

Download LightTPD for Windows from At the time of writing, the current version is 1.4.13 and the downloaded installer is called lighttpd-1.4.13-win-setup.exe. Run the installer. Note that, by default, LightTPD installs itself into the directory C:\lighttpd - and it is recommended that you leave it here.

Now Create Your Project

Select New|Project|Ruby In Steel and click Rails Project. Give the project a name ('Rails1' should do) and click OK.

When the Create Rails Project dialog appears, click 'None' in the 'Select database options' group at the top left then click OK.

At this point a dialog appears showing some details about the project you are starting. Click Proceed.

After a few moments, your new Rails project will be created. You are now ready to set the web server script to LightTPD. To do this, select Tools|Options|Projects and Solutions and select Ruby In Steel. Set Web server script to lighttpd_server.bat. (You can click the browse button [...] in order to select this file from an Open dialog…

 select server script

In the Options dialog, set the Rails debug script to scgi_service.rb (once again you can browse and select this file).

Also in Options, ensure Use the fast Cylon Debugger is checked. The server port shown in this dialog is only used when running a server script (for example, with WEBrick) and this option is not relevant to LightTPD.

Click OK to close the Options dialog.

Start The Server

You are now ready to start LightTPD. Select Ruby|Start Server. You should see a command window appear confirming that the LightTPD server is running…

NOTE: If, at this stage, you see an error message stating that "port: 80" is already in use, you will need to edit LightTPD's port manually to some other value. This is set in the LightTPD configuration file, lighttpd.conf, in the \config directory under your current Rails application's directory. Open this file in Visual Studio. Search for the following entry:
 #server.port  = 81
…and remove the comment character #, so that the entry is now:
 server.port  = 81
Save the file and try to start  LightTPD again (as explained above).

Click and Debug!

We are now going to check that all is well by starting Rails and displaying its welcome page. To do this, select One-click Rails Debugger from the Ruby menu. You should see the Visual Studio Ruby console displayed a mesaage stating that the LightTPD service is running.

Check that Rails is running by entering the following URL in a browser (Note: if you edited the port number in the config file, remember to substitute 81 – i.e.  http://localhost:81 - or whatever port number you specified, in the address entered) :


You should now see the Rails intro page:

Rails intro page

Stop Rails

To stop Rails, go back into Visual Studio and select Debug|Stop Debugging.

Generate A Controller

To generate a controller, select Ruby|Generate and ensure the Controller radio button is selected. Enter in the Value textbox:
Then click OK.

Generate controller

Open /app/controllers branch of the Solution Explorer and open the file helloworld_controller.rb. Add the following code between the class declaration and its end keyword:

 def index
     render :text => “hello world”

Save the file.

Set a breakpoint on the line:

render :text => “hello world”

Start the Rails debugger again by selecting Ruby|One-click Rails Debugger.

Debugging with Cylon

In your web browser enter:


(remember to use the actual port number if this is not 80)

The Rails program should now hit the breakpoint and you should see…

Cylon stopped at a breakpoint

When stopped at a breakpoint you can use all the usual Ruby In Steel debugging features to trace through the code and monitor variables and expressions in the various debugging windows.

Continue by pressing F5. you should now see the "hello world" page displayed in your web browser…

And that's it!

See Also