How to use Eclipse for Ruby on Rails

I have been trying to use different alternatives to run Ruby on Rails locally with available tools in the market. I have used nice editors like Sublime Text 2, notepad++ and others but I really wanted a programming IDE that I could interact with (navigate through the classes, files, etc. with easy clicks). I tested also Rubymine which is the Ruby on Rails IDE but still I wondered if there was another solution available. Then I discovered that I could use one of my favourite editors...eclipse with the DLTK (Dynamic Language toolkit) to achieve my purposes.

In this post I will cover the necessary steps you need to do to get your eclipse IDE up and running to become your Ruby on Rails IDE.

First you need to get a version of eclipse. (The Eclipse Java EE IDE for Web Developers in my case)

For this article I will use the Eclipse Luna SR2 version so everyone has a reference. You can use the version you currently have installed as the DLTK packages can be installed separately.

Once eclipse is up and running, go to Help menu and Install new software. A new window will open and in there use the following URL:

   dltk - http://download.eclipse.org/technology/dltk/updates-dev/latest/


Select the packages DLTK and DLTK test and click Next.


Now you can create Ruby Projects:


Once we want to create a new project, the system will ask for an interpreter. We will have to configure where ruby.exe is located:


Click on Configure interpreters and add a new ruby interpreter pointing to the location where your ruby files are.


Now you can add your files into the project and start working with it. Here is a simple example that I have coded for this article that you can test:


If you try to run this in eclipse, an error is thrown in the console:

C:/luna/eclipse/configuration/org.eclipse.osgi/898/0/.cp/testing/dltk-testunit-runner.rb:252:in `block in <top (required)>': uninitialized constant Test::Unit::UI::SILENT (NameError)

To fix this, you need to open:

C:/luna/eclipse/configuration/org.eclipse.osgi/898/0/.cp/testing/dltk-testunit-runner.rb and solve this by commenting out:

#autoRunner.output_level = Test::Unit::UI::SILENT
and adding the following:

autoRunner.runner_options[:output_level] = Test::Unit::UI::Console::OutputLevel::SILENT

as shown in the image:

and run the test again.

Now your IDE is ready for action.
Jordi

Comments

  1. How do you generate the rails project? I can't find such and option.

    ReplyDelete
  2. It is nice blog Thank you porovide importent information on ruby on rails programming in eclipse thakyou give the information for all and also i am searching for same information to save my time.
    Ruby on Rails Online course

    ReplyDelete

Post a Comment

Popular Posts