3

I'm about to get used to work with Java in Android Studio. The great thing there is that everything is strongly declared. So when I type MyClass.someme..., the IDE offers me advanced code autocompletion features. The development is rapid and pleasantly.

But then I wanted to learn RubyOnRails. I'm in love with JetBrains products and so I've installed RubyMine on my Windows machine.

Despite of a bag of problems with Windows enviroment, I was confused with not-so-well working code completion. Even if the method is known by the IDE (it can be found by Ctrl+B combination), it does not offer it in popup menu (discover the picture).

Function from railstutorial.org:

# SomeControllerHelper.rb
# Redirects to stored location (or to the default)
def redirect_back_or (default)
  redirect_to(session[:forwarding_url] || default)
  session.delete(:forwarding_url)
end

Why, RubyMine?

Is there any way to fix this problem? Are there any better IDEs with really smart code completion?

Vlad Faust
  • 542
  • 6
  • 18
  • Ruby in dynamic typed language which means that you don't type method return types or argument types. Another thing is metaprogramming which is done during runtime. Both of those things make autocompletion a lot harder to implement than for example in Java which is just static typed, compiled language. RubyMine is best IDE for Ruby language. – Bartosz Łęcki Aug 12 '15 at 21:18
  • This is an answer, @BartoszŁęcki. Thanks! – Vlad Faust Aug 12 '15 at 21:48

2 Answers2

7

As mentioned before, Ruby's code completion is very complicated due to dynamic typing. Switching from C#/Java I've been struggling with it for some time and I've found one way to at least mitigate it a bit. Example:

def extract_data_from_this_array(input_array)
  # some code
end

Suppose you want to deal with the array you're getting as an input. You type input_array and no methods or all methods are listed, because Ruby has no idea that it's an array. What I do is write:

Array.new.

And RubyMine suggests all Array methods. It helps a lot when you've just picked Ruby.

rsqLVo
  • 488
  • 5
  • 8
2

Although, RubyMine doesn't work for ALL code completion all the time due to the dynamic nature of Ruby. But, I still find it the BEST Ruby IDE for code completion, method navigation, searching features.

Here is a screenshot to show you how to configure RubyMine for Code Completion:

enter image description here

Here is a good tutorial by Justin Gordon which shows some awesome features of RubyMine which may interest you.

I don't know any other Ruby IDE that has smarter code completion than RubyMine. In fact, a vast majority of Ruby programmers doesn't even use an IDE, rather they use a Text Editor!

Here are couple of short sitepoint articles that would give you more insights:

Which IDEs do Rubyists Use?

What Editor Do Rubyists Use?

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110