My First Impressions of NetBeans Ruby IDE for JRuby on Rails Development

September 15, 2007

In a previous post, I went through my thought process for choosing Aptana/RadRails (on the Eclipse platform) as my Ruby on Rails(RoR) IDE. Well, that didn’t last long.

In recent weeks, I started seeing several posts about using NetBeans for RoR development, and in particular, this post persuaded me to download it and try it. I just started using the NetBeans Ruby IDE this week, and I may be just about ready to convert for good.

NetBeans, UI seems to be pretty logically organized, and its various panels somehow seem better integrated than similar panels (or “views”) in Eclipse. Compared with the functionality of RadRails, NetBeans Ruby/RoR features seem to be more mature, more robust, better organized and easier to use. Basically, it looks like it offers at least as many features as RadRails does, but seems to perform each function just a little bit better. I am also reassured by how much more active development seems to be going into the NetBeans Ruby IDE compared to RadRails.

And in general, I have always been a little uncomfortable with certain aspects of Eclipse. Although it has a lot of mindshare among developers, and it takes a very generic approach (its really an IDE platform more than a true IDE itself), it really functions best as a Java IDE, with its related tools. Although I have PHPEclipse, PyDev and RadRails installed, none of them are that mature–not much more than what a good programming text editor would give you. (Sorry, I hate to criticize these projects–I really admire what they are trying to do, and I certainly could have done more as a developer to support them.)

Also, I have been using Eclipse for some years now, and it has always been unstable to one extent or another. Again, if I just have the default Java tools installed, its decently stable, but as I tried to add new modules, even modules that have been around much longer than say, PyDev, I invariably ran into problems, which was especially surprising considering that Eclipse is supposed to be designed as a generic platform. You would think that a problem with say, RadRails, would be limited to just that “perspective” and not make the entire platform unstable. But this hasn’t been my experience. A few times, I have run into problems where the only solution was to completely remove and reinstall Eclipse, and I know I’m not the only one who has had to do this.

Although I agree with the Pragmatic Programmers advice on using one IDE and learning it in depth, and NetBeans appears to be even more heavily biased toward Java development, all things considered, it may be the best choice for my work. Even though I am using a development build of NetBeans, and I do see occassional problems, it is much more stable than my “stable” release of Eclipse. Also, I primarily do most of my development in Java, and even as I am learning Ruby, my target deployment is in a JRuby/Tomcat environment, which NetBeans also supports nicely. I still do some development in other languages, especially PHP, but this tends to be in smaller projects as a freelancer, whereas I use Java and now, RoR, in my day job for larger projects. So, I don’t have a problem using a simpler text editor for these other languages, especially since, as I said, this is the level I felt like I was functioning at with Eclipse anyway. For that matter, I don’t see any reason why I couldn’t use NetBeans as a simple text editor, and maybe if people stop focussing so intently on Eclipse, better support for other scripting languages will find its way into NetBeans.

And even though NetBeans is a good IDE for general Ruby development or typical RoR development, in my opinion, its JRuby/JRuby on Rails support is really what makes it shine. In my experimentation this week, as someone not only new to NetBeans, but also still very new to RoR and running it on JRuby, here are some notes I took to start a new JRuby on Rails project in NetBeans:


  • Assuming you already have Ruby and Rails installed, download the latest build of the NetBeans Ruby IDE from:
    • http://deadlock.netbeans.org/hudson/job/ruby/
  • When creating a new RoR project, click on options to use ActiveRecord-JDBC and create Rake tasks for WAR files in the new project wizard.
  • Register this Rails plugin repository with NetBeans, by right clicking on the project name and selecting “Rails plugins”:
    • http://agilewebdevelopment.com/plugins/script_list
  • Download the MySQl JDBC Jar file from the MySQL site and register it in NetBeans under project properties (right click on the project name, and select properties)
  • Install ActiveRecord-JDBC on the command line:
gem install activerecord-jdbc --no-rdoc --no-ri
  • WAR files point to production database by default. So, you probably want to leave the development and test databases configurations as is, and run the application through the WebBrick server during development, but set up the production database configuration like this to run inside Tomcat/JRuby:
 production:
   adapter: jdbc
   driver: com.mysql.jdbc.Driver
   url: jdbc:mysql://localhost/sample_production
   username: root
   password:
   host: localhost
  • I also created a config/war.rb file and added this to it (check version):
maven_library 'mysql', 'mysql-connector-java', '5.0.7'
  • You might also have to create a lib/java directory and store jars in there in addition to configuring in war.rb.
  • When running rake, it must be done in the context of jruby:
jruby -S rake db:migrate RAILS_ENV="production"
  • (JRuby is embedded with the NetBeans IDE at nbrubyide/ruby1/jruby-1.0.1/bin/jruby, so depending on how your environment is set up, you may want to point to this version directly, at least to get started.)

I offer these notes for anyone who may find them useful. Basically, these notes are adapted from the pages that follow, while taking into account the things that NetBeans does for you:

  • http://www.headius.com/jrubywiki/index.php/Rails_Integration#Connecting_to_a_database
  • http://www.headius.com/jrubywiki/index.php/Running_Rails_with_ActiveRecord-JDBC

6 Comments »

Comment by Roman Strobl
2007-09-16 00:15:16

Hi, thanks for giving NetBeans Ruby support a try. The beta version of NetBeans 6 is coming during this week, so I suggest to move to this version, because it will be more stable than the development builds.

 
Comment by Arun
2007-09-17 06:30:20

Thanks for trying NetBeans. Here are couple of other entries that you may find relevant:

http://blogs.sun.com/arungupta/entry/jruby_on_rails_netbeans_and
http://blogs.sun.com/arungupta/entry/screencast_web8_jmaki_on_rails

 
Comment by admin
2007-09-17 06:49:28

Thanks Roman and Arun, I’ll check these out.

 
Comment by Lori M Olson
2007-09-18 07:20:29

You should give 3rdRail a try before giving up on an Eclipse based tool.

http://cc.codegear.com/Free/3rdrail

Comment by admin
2007-09-18 07:49:42

Thanks for the pointer, I wasn’t aware of this option.

 
 
2007-09-26 13:14:47

[...] IDE para Rails, e anunciado como grande concorrente para o Eclipse. O site Stone Mind fez uma primeira análise positiva do NetBeans (o RoR Lituânia também), com direito a algumas dicas. Também falamos dele aqui. Se [...]

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.