News

RadRails 1.0 Adds Options for Ruby Coders

A fairly new development tool for Ruby coders is RadRails, a free integrated development environment (IDE) that works as an Eclipse plug-in. In March, Aptana released version 1.0 of this open source Ruby on Rails (ROR) framework-based IDE.

Aptana, a provider of infrastructure solutions for Web developers, adopted RadRails in 2007. The company made some improvements to this IDE with version 1.0, which are described below. In addition to plugging into Eclipse, RadRails 1.0 works with the company's Aptana Studio product, a commercial development environment for rich Internet application and Web development.

RadRails 1.0 supports Rails 2.0, the popular Ruby-based framework, as well as JRuby, which provides integration with Java. The latest version of RadRails provides full implementation of the Eclipse Ruby Development Tools (RDT) project, which is new with this release. In earlier editions, RDT had to be installed first. RadRails 1.0 also provides bundled auto-installing gems for Rails applications. A Ruby gem is a Ruby software package that provides Ruby class libraries for Rails development.

Installation
For those who want to use RadRails 1.0 in the Eclipse JEE edition, first install the plug-in for Aptana Studio using this Studio link. Next, install RadRails using this Rails link.

Next, we shall discuss the new features in RadRails 1.0.

Ruby Interpreter and Database Support
RadRails 1.0 supports the Matz's Ruby Interpreter (MRI), JRuby and Rubinius. MRI is the official Ruby interpreter and is the most commonly used, and is named after the Ruby founder Matz. JRuby is a Java-based implementation of Ruby. Rubinius is a high-performance virtual machine (VM) and compiler for Ruby. RadRails 1.0 includes a preinstalled Ruby interpreter that works as a JRuby virtual machine (VM).

To install a standard (MRI) VM, install Ruby using the Ruby Windows installer and configure the Ruby VM using the following toolbar menu selection: Windows>Preferences>Ruby>Installed Interpreters (Figure 1). The Ruby Interpreter that has the corresponding checkbox selected is used as the Ruby interpreter for Ruby projects.

Figure 1
Figure 1. Configuring Ruby interpreters. (Click image to view larger version.)

By default, the Rails applications created with RadRails 1.0 have the database.yml configuration file configured with sqlite3 database, for which the sqlite3 gem is required to be installed. Another database, such as MySQL, for which the mysql gem is required, may also be selected when creating a Rails application, as shown in Figure 2.

Figure 2
Figure 2. Selecting database for Rails application. (Click image to view larger version.)

Rails Shell Console
The RadRails Eclipse perspective includes Eclipse view Generators to generate models/views/controllers, Eclipse view Rake Tasks to run rake tasks such as rake migrate, and view Rails Plugins to add plug-ins.

If you would rather run ROR commands on the command-line, RadRails 1.0 provides a Rails shell to run Rails commands. ROR commands such as rails, rake, script/generate, script/plug-in, and gem may be run to create Rails applications, create model/view/controller/scripts, run Rake tasks and install Ruby gems. For the Rails shell, select "Open a Rails Shell" as shown in Figure 3. You would have to install the Rails gem before running the Rails command though.

Figure 3
Figure 3. Rails shell. (Click image to view larger version.)

Debugger and Integrated Profiler
Improvements have been made to the integrated debugger in RadRails 1.0. Ruby Gem ruby-debug is preinstalled in RadRails 1.0. Breakpoints may be added to Ruby code using Add Breakpoint and breakpoints may be removed using Remove Breakpoints in the Ruby file.

To debug a Rails application, start the server in debug mode by selecting "Start server in debug mode." In the Debug mode, the application suspends at breakpoints, which may be used to debug the application. Variable values may be set, scripts may be run, breakpoints may be removed and expressions may be evaluated in debug mode.

The RadRails 1.0 commercial version provides a profiling tool to display Call Graphs and Hot Spots in the Rails application. Among other features, the commercial version also includes a JSON editor, JavaScript debugger and an XML editor.

Code Completion
RadRails 1.0 provides a code completion feature with method call arguments inferencing and type inferencing. Code completion is provided for ActiveRecord model fields and finders. RadRails 1.0 provides automatic indexing of Ruby code, including a listing of all of the gems and libraries in the Rails project for easy navigation. It also enables formatting across HTML/CSS/JavaScript editors and also provides support for auto-closing of HTML tags.

Enhancements in code warnings and analysis have been included in RadRails 1.0. Also, syntax updates from Ruby 1.8 to 1.9 have been included. The ERB/RHTML and YML editors have been revamped and include support for color preferences as shown in Figure 4. It enables Ruby code elements such as comments and errors to be color coded.

Figure 4
Figure 4. Setting color preferences for Ruby code elements. (Click image to view larger version.)

Type Hierarchy and Call Hierarchy
RadRails 1.0 provides type hierarchy for a selected class. Type hierarchy is the hierarchy of super-class types for a class. For example, select the CatalogsController class, right-click and select Open Type Hierarchy, as shown in Figure 5. The Type Hierarchy for the CatalogsController class gets displayed; CatalogsController class extends the ApplicationController class, which extends the ActionController::Base class. Similarly, the Call Hierarchy for a method invocation may be displayed by selecting Open Call Hierarchy. Open Type Hierarchy and Open Call Hierarchy may also be selected from the Navigate menu in the toolbar.

Figure 5
Figure 5. Type hierarchy. (Click image to view larger version.)

To navigate to the declaration for a variable, class, or method select the variable/class/method and select Open Declaration from the pop-up menu. Open Type in Hierarchy may be selected to display matching types.

More information on the features in RadRails 1.0 is available here at Aptana's Web site.

About the Author

Deepak Vohra, a Sun-certified Java programmer and Sun-certified Web component developer, has published numerous articles in industry publications and journals. Contact Deepak at [email protected].