RubyMine: Code Insight for Ruby and Rails

This article was sponsored by JetBrains. Thank you for supporting the partners who make SitePoint possible.

If you are developing in Ruby or Rails, you may have heard of RubyMine.

RubyMine is an IDE for Ruby and Rails developed by JetBrains. It’s been around for almost 10 years and has a huge user base. And yet, as we visit industry events and shows, we often get the question: “Okay, what does RubyMine do that a text editor can’t?”. By no means am I trying to diminish the value or usefulness of free code editors, but “let’s just say, there’s a lot!” is my usual response as I fire the IDE for a quick demo. In this post I’d like to tell you about the key thing that makes RubyMine stand out: Code Insight.

Code Insight includes things like smart code completion, code navigation, language-specific inspections with quick-fixes, smart notifications, and in-editor quick documentation. So many terms, but what do they do and why would you need them? Let me have your attention for five minutes before you switch back to your $EDITOR$ and get on with your work.

Automatic Code Completion

This feature doesn’t need any introduction as it exists in all the popular editors. However, RubyMine’s autocompletion is not limited to Ruby/Rails built-in keywords and text-based autocompletion. As the IDE indexes your whole project on each startup, it can autocomplete almost any relevant entity regardless of where it’s defined. You don’t need to open a file in a separate tab to autocomplete any declarations from it – RubyMine knows everything about your project already!

Say, you are creating a new table. RubyMine will suggest possible autocompletion options of relevant column types and properties as you’d expect:

RubyMine - creating a new table

But wouldn’t you like to have access to the columns later, when you are working on a model? Of course you would, and the IDE will do that for you the same way as it autocompletes all the built-in Rails stuff:

RubyMine - IDE autocompletes

How about the ability to also autocomplete methods, earlier defined in the model, say, in controllers or other ruby files in your project? You got it:

RubyMine autocomplete methods

The IDE won’t make autocomplete suggestions for column names where you are expecting to see methods defined in the given model, and vice versa. This is a very important feature that makes the RubyMine completion stand out from other editors.

You can work with your views in the same manner. I am not talking about just the basic HTML and ERB syntax suggestions, they are a given, but actually all the specified entities in your project:

RubyMine - work with your views

Go to declaration (aka Go to definition)

When I talk with our customers, I always ask them what their favorite RubyMine feature is. The top reply of all time is “Go to declaration rocks!”. While I’d rather hear success stories about our GUI debugger or other advanced features, positive feedback is always good! But I got curious as to why this happened time and time again, so eventually I started comparing RubyMine’s Go to declaration with Go to definition that exists in some popular editors.

Without a doubt, the IDE proved to be far more reliable when navigating to declarations. Just use ⌘+Click | Ctrl+Click (or ⌘+B | Ctrl + B if you put your caret on the desired object) and jump to the definition you need:

RubyMine - Go declarations

Not only can you easily jump to a class, method, or any other entity declaration in your project, but you can also navigate to gems and their entities’ definitions. Need to rewrite a bit of Ruby on Rails to make your project better? Say no more:

RubyMine - Go to declaration rewrites

I tried to find some plugins that could do the same for the code editors I’ve been checking out lately, but they haven’t helped much. If you know some, your suggestions in the comments would be much appreciated. But until then, I’m sticking with my story: Go to declaration alone should make you want to give RubyMine a shot!

Static Analysis

What I love about Atom is its solid syntax highlighting. It won’t let me miss a closing tag or end. I also discovered a great plugin that underlines all RuboCop offenses and even allows you to autocorrect offenses for the file. Kudos, Atom and the plugin creator, this is cool!

Continue reading %RubyMine: Code Insight for Ruby and Rails%

Source: Sitepoint