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:
Enabling support for jQuery
- In RubyMine, go to Settings » JavaScript Libraries and add a new library.
At this point we have two options for type:- Debug: file containing the uncompressed JavaScript code. [jquery-1.5.1.js]
- Release: the minified version of the code. [jquery-1.5.1.min.js]
- Make sure to Apply the changes before continuing, then go to Usage Scope and enable the library for the current project:
- Finally, both jQuery code completion and navigation are working as expected.
Enjoy!
Update: Thanks to the JetBrains' Easter Sale, you can could get RubyMine for 30% off.