Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage Articles NetBeans: Ruby Developer's New Best Friend (Part 3)

NetBeans: Ruby Developer's New Best Friend (Part 3)

This item in japanese

This article is the final part in series of articles about NetBeans & Ruby. You can read the first two parts of the article which is an introduction to the NetBeans Ruby support here (part 1, part 2).

This article covers features which were not covered in the previous two parts and discuss various extensions you can install to make Ruby development easier and more fun.

Additional hints & quick fixes

Tor Norbye, the main developer of NetBeans Ruby support, has been working hard on increasing the number of intelligent quick fixes in the editor. Some of them are available out of the box, while some of them need to be installed extra. The reason for this is that they were created after the release, and they will be most likely included in the next release of NetBeans. Let's take a look at the most useful quick fixes with simple code examples.

The deprecation hints appears in case that you use a construct which is being deprecated. Thanks to these warning you can make sure that your code adheres to latest Ruby coding standards.

If you write too much code on one line and you would like to expand it to multiple lines, you can use the following quick fix:

The code gets formatted in multiple lines automatically:

The following quick fixes are available as plug-ins from the update center. You can use the plug-in manager (Tools | Plugins) to get them - the name of the plug-in is "Ruby Extra Hints".

The IDE can detect if you "shadow" another variable, for example in a nested for loop:

There are several ways how to resolve this situation, so you can choose the option which is better for you. You can also disable the hint if you don't want to see this type of hints anymore.

You can also convert easily a do/end block into an {}-block:

The IDE will also help you with code style - of course it's still up to you to write clean and readable code but you will get suggestions (which can be really useful for people who move from another language to Ruby).

Some of the quick fixes are specific to rails applications, for instance if you have a controller action which is missing a corresponding view file following hint appears:

You can also use some of the quick fixes to refactor your code - introduce new variables, extract methods from existing code, etc.:

All of the quick fixes can be enabled or disabled in the options dialog, so if any of the light bulbs would be annoying for you, go to Tools | Options | Ruby | Hints and disable it.

There are other quick fixes available, to see the complete listing please visit the Ruby Hints wiki page:

Custom color themes

Many Ruby developers are used to the look and feel of editors such as vi and emacs. These editors use black background color, so the default white background in NetBeans might be a bit too bright for some of you. Luckily NetBeans supports color themes and there are two schemes which are more similar to the terminal text editors: Norway Today and City Lights. You can also create your own color theme. To change the color theme go to Tools | Options | Fonts & Colors and switch the profile to the one you like the most.

Database-related tooling

Database tooling which is available in NetBeans is not Ruby specific. You can manage databases directly from the IDE. JDBC drivers are provided out of the box for JavaDB (also known as Apachle e Derby), MySQL and PostgreSQL, but you can connect to any other database after specifying the location of the JDBC driver and the database URL. Then you can browse the database tables, their structures, write SQL queries inside of an editor with syntax coloring, run the queries and browse results. You can also create new tables and backup/restore your table data. All of this functionality is available out of the box - so you don't need to install any additional plug-ins. The database management is located in the Services tab as seen on the screenshot.


NetBeans also provides experimental support for Rspec. RSpec is a Behaviour Driven Development framework with tools to express user stories with executable scenarios and executable examples at the code level. Once you install the "rspec" Ruby Gem (use Tools | Ruby Gems), your Rails projects will contain a spec directory which can contain specification files. If you open one of these (you can use the Goto Test action described above), you can run the specs by using Run File. This will run the current spec file under rspec.

Extra plug-ins

You can install other experimental plug-ins to make Ruby coding more comfortable:

  • Spell Checking - background spell checker that highlights mispelled words in comments
  • Rectangular Selection - you can select rectangular pieces of code Tabs - this plug-in highlights any tabs in your code so that your code can be made tab-less
  • Trailing Whitespace - this plug-in highlights trailing whitespaces
  • Quick File Chooser - replaces the IDE file chooser with one optimized for keyboard usage
  • Build Monitor - provides monitoring functionality for Hudson continuous build server
  • TODO Highlighter - highlights any todo markers in the code

Most up-to-date information about extra plug-ins is available on this wiki page:

Vi and Emacs support

Getting used to new keyboard shortcuts can be really hard. However with NetBeans you don't have to give up the comfort of your existing editor - there is a plug-in for vi available which has not only similar keybindings but also provides similar command-related functionality as vi/vim. Make sure to try this plug-in out if you are a vi/vim user:

There's no plug-in available for Emacs, however you can switch to Emacs keybindings in Tools | Options | Keymap.


A high number of different screencasts has been recorded to make it easier for developers to learn new Ruby development-related features. These screencasts are a part of the NetBeans Ruby learning trail. It is recommend for anyone who wants to quickly learn to do Ruby development with NetBeans:

Other languages

You may also wonder what are the other languages supported by NetBeans. Obviously Java support is the most advanced of all the supported languages, however you can find strong support for more than just Java & Ruby. NetBeans has been supporting C/C++ development since version 5.5. JavaScript support has been added in NetBeans 6.0 and it is planned to be enhanced in the upcoming versions. Groovy/Grails support is under development with first target release as plug-ins for NetBeans 6.1. You can get plug-ins for languages such as Erlang and Scala. Some older languages such as ASM are also supported, so make sure to search for plug-ins in case you're using some other languages which was not in the above list.

When discussing languages it is also worth to mention project Schliemann which provides generic language support. You can use Schliemann to create basic support for any language (features such as syntax coloring, code folding, indentation are really easily configured). Thanks to this project NetBeans can provide basic support for lots of different languages - and if you invent your own language make sure to look at Schliemann to get some nice support in the IDE. More information about project Schliemann is available in NetBeans wiki:

More information

You can find additional information about Ruby support in NetBeans on its wiki page.

Various demos and tutorials are available from the main Ruby documentation page.

Finally you can download the NetBeans IDE for free.

You can either choose to install a small version of the Ruby-only IDE (a special bundle is provided) or full-blown Java IDE with Ruby support. It is also possible to add Ruby support to the Java-only IDE using Tools | Plugins.

Make sure to try out Ruby support in NetBeans. If you develop in Ruby a lot, you may find that NetBeans is the IDE you have been looking for!

Rate this Article