Thursday, April 21, 2011

Enabling jQuery support in RubyMine

Last week we saw how to enable jQuery support in your Rails 3.0.x app for all your UJS needs.
But after @dhh's leak, today we know for sure: Rails 3.1 will ship with jQuery as the default Javascript library! That's great news and I believe it will clear any doubt from a beginner's mind on which JavaScript library she should focus on. If you still plan to use the Prototype helpers/RJS though, it will be as easy as upgrading your application to use the prototype-rails gem.

But how jQuery-ready is RubyMine?

While experimenting with Unobtrusive Javascript using RubyMine, there was one improvement brought by version 3.1 that particularly drew my attention:

Autopopup code completion — code completion suggestions appear instantly as you type and work for Ruby, ERB, JavaScript, HTML and other files.

Still, as reported in issue RUBY-5026, RubyMine's autocomplete cannot automagically talk jQuery. By default, the suggestions will be based on Prototype.js; furthermore, if you --skip-prototype, they will be even more limited:
RubyMine's lack of jQuery support

Enabling support for jQuery

  1. In RubyMine, go to Settings » JavaScript Libraries and add a new library.
    At this point we have two options for type:

    Attaching new JavaScript libraries in RubyMine
  2. Make sure to Apply the changes before continuing, then go to Usage Scope and enable the library for the current project:
    Enabling the library for the current project
  3. Finally, both jQuery code completion and navigation are working as expected.
    Enjoy jQuery support in RubyMine!

Update: Thanks to the JetBrains' Easter Sale, you can could get RubyMine for 30% off.


  1. Awesome! I'm really enjoying RubyMine.

  2. Nicely done! Now if only we could get the debugger to work -