If you’re an IntelliJ user like me, and have recently been bitten by the RoR bug, you’ll be glad to know that there’s a plugin on the way. It’s still in it’s infancy, lacking a lot of features, and is therefore not in the repository, but that doesn’t mean we can’t play around with it. What follows is a brief tutorial on how to locate, install, and use the ruby plugin…
First you need to check out the sources from the Subversion repo:
svn co http://svn.jetbrains.org/idea/Trunk/ruby
Use Ant to build it (run ant from the directory you co’d to, where the build.xml file lives). The build process should generate a jar file in dist/ called ruby-SNAPSHOT.jar.
Next, make a new directory in your IDJ plugins directory called ‘ruby’ and make a lib directory in there. Copy the jar to $IDJ_ROOT/plugins/ruby/lib. On OS X, this path is something like /Applications/IntelliJ IDEA 6.0.2.app/plugins/ruby/lib/.
Start IntelliJ. Go to Settings → Project Settiings → Project Structure. In Global Resources, under JDKs, right click and add a Ruby SDK. On OS X, you’ll want to point it at /usr/local, or whereever your copy of Ruby has been installed.
Now you should be able to create a new project and select Ruby SDK from the JDK list (heh). Create a single module project, select Rails as your module type, and set the Ruby SDK for the module. Finally, you’ll be given the chance to generate a new Rails application skeleton, generate missing files, or use an existing Rails app. Go ahead and create a test project and generate a new Rails framework. I’ll do all the work for you and populate the project explorer with that oh-so-familiar directory structure. Check out that ugly Ruby icon they’re using. Jeeze, what is that?
Right click in the project explorer and select New → Controller. Name your controller test and add an action name hello. Click OK. IDJ will run the Rails generator and update the project explorer. You now have a TestController with a hello action, the corresponding view template, and the expected test stubs.
You can select Run → Run… to start a WEBrick server and test your app. There are some bugs here. First of all, there is no run output in the console view where you’d expect it to be. No web browser is launched, no indication is given of what port number the server gets bound to. Worse, you can’t seem to kill a running WEBrick server without killing the process from a terminal. So yeah, there’s obviously still some work to do here. For now, I’d suggest running WEBrick from the command line (RadRails still wins here, at least). No command completion or real debugging support is available yet either, but hey.. it’s a start. It’s functional, you can run tests from within the IDE, you get basic code formatting, syntax highlighting, etc.
For more information, check out the JetBrains Project Homepage for the ruby plugin, where you’ll find a link to the roadmap and discussion groups. You’ll note that there are plans for autocompletion, ability to browse to symbol, proper YAML, RXML support, etc. I really hope that development continues on this. IDJ is much-loved amongst the Java community, and could be a huge hit in the Rails community if they get a slick, fully functional plugin out there.
Develop with pleasure ;-).