IntelliJ IDEA and Ruby on Rails

Not exactly Ajax related, but I thought I'd share it since it might prove useful. I've been evaluating a few Rails IDE's for my firms lately, including IntelliJ IDEA 7.0. On Linux, it has been an underwhelming experience. Specifically, there are two problems that get in the way of productive work:

  1. The IDE calls rails as follows:  /usr/local/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /usr/bin/rails ProjectName --force, which is a problem if rails is a shell script, as it is on many system.
  2. The symbolic link from vendor/rails  to . causes the IDE to go into an infinite recursive scan of the ruby code.

Yuck.

The solution to the first problem is to provide a Ruby wrapper to the rails shell script. First you move /usr/bin/rails to /usr/bin/rails.sh. Then you create a new /usr/bin/rails with the following content:

#!/usr/bin/ruby

exec('/usr/bin/rails.sh', *ARGV);

Now, when the IDE tries to execute Rails with the Ruby runtime, it doesn't barf. So far so good.

The second problem doesn't have such a simple solution. Since the IDE starts scanning the source tree right after Rails gets done generating it, you don't have a chance to fix things before the death spiral begins. So, our hack is to first delete the symbolic link, then exclude it from the source scan, then re-add it when it is safe.

  1. While the IDE is doing its "...rails/rails/rails/rails/rails..." scan, delete the symbolic link: cd vendor; rm rails
  2. The scan should finish quickly now. Once it is done, create a simple directory in the vendor directory: mkdir rails
  3. Now open up the Module Settings dialog and select the vendor/rails directory and exclude it. Click OK.

  4. Remove the directory and recreate the symbolic link: rmdir rails; ln -s . rails

And you are done. Double yuck. What a hack.

JetBrains, are you listening? Since many Rails developers use Linux as their desktop platform, maybe you could fix these issues soon? This ain't like IE on the Mac, people actually do use it.

Technorati Tags: , , ,

Related posts:

  1. A Java Programmer’s transition to Ruby on Rails
  2. Ruby on Rails Internship
  3. From JSP to Ruby on Rails: First thoughts on front-end coding conventions
  4. “Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client” Also up on IBM Developerworks
  5. What makes Ruby/Rails Development Fun

Topics: ,

Comments: 1 so far

  1. Please comment the issue http://www.jetbrains.net/jira/browse/RUBY-385 and describe your environment(rails and ruby versions, plugin version, OS). What version of Rails do you use? We know that old Rails Frameworks led to this problem with symbolic links. But on version 1.2.3 and higher all is ok.

    Comment by Roman Chernyatchik, Friday, November 16, 2007 @ 12:48 am

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com