10 Replies Last post: Oct 8, 2013 10:31 PM by Rasmus Schultz  
Rasmus Schultz Newbie 9 posts since
May 8, 2013
Currently Being Moderated

Sep 27, 2013 11:59 PM

auto-completion/inspections: trying to understand the role of RubyMine (and Rails)

I've been working with PhpStorm for a while, and I was expecting the same (awesome) experience from RubyMine, which I am currently trying out, and it has been pretty disappointing so far.

 

I'm fairly new to Ruby and Rails. I am working with Ruby 2.0 under JRuby, and Rails 4.

 

For the most part, nothing auto-completes, and practically everything lights up with failed inspections.

 

If I get anything in an auto-complete list at all, it's usually either a list of every method in the entire codebase, it's empty, or in a few cases (such as with ActionMailer) it actually auto-completes methods that, when called, turn out not to exist, while methods that do exist do not show up at all.

 

Even basic things like typing "request." in a controller/action-method does not provide me with anything useful.

 

How come questions along the lines of these usually go unanswered?

 

http://devnet.jetbrains.com/message/5270687

 

http://devnet.jetbrains.com/message/5485130

 

It seems like these problems stem from the fact that many methods are generated at run-time, and cannot (feasibly) be inferred by parsing the source-code. (short of running it, obviously.)

 

From what I've seen so far, Rails developers generally don't annotate or comment much, so there is not much information for the IDE to consume - it seems that attitude is that, as long as you learn various conventions, this is a non-issue and you don't need the annotations, which would just be more stuff you'd have to maintain?

 

I also see that, when people ask these questions in other forums, they are generally met with smug remarks and rude or superior attitude - I hope that's not going to be the case in this forum.

 

Perhaps my problem here is not so much Ruby, or Rails, or RubyMine, but more of a social issue?

 

Short of religiously documenting every run-time generated method, parameter and instance-variable with annotations, is there any way to get the same enjoyable experience I had with PhpStorm in RubyMine?

 

Having to document everything creates the same maintenance burden as having to declare the same things in various other languages with typed parameters and properties - if I have to write and maintain annotations for every method, where is the advantage in getting all of these things "for free" (without effort) by generating the methods at run-time?

 

If I have to disable inspections and don't rely on features like refactoring, where is the advantage of RubyMine over a "dumb" text-editor?

 

If the only reliable way to construct method-tables from run-time generated classes, is to actually execute the code and inspecting the method-tables, why doesn't RubyMine do that? (If the Ruby language doesn't allow for sufficiently detailed static analysis, is static analysis the right approach?)

 

If RubyMine does support some (or all) of the standard Rails method-generation conventions, does it support those "explicitly" for the framework, or is the Ruby-analysis "generic" enough to actually support Rails? If it supports them explicitly, where does that leave you when you add on a bunch of third-party modules that introduce more conventions and generate more methods?

 

I'm sorry, I realize this is a lot of questions, and please don't take any of it offensively or as me trying to attack your product or the Ruby or Rails community.

 

Coming from languages like PHP, C#, JavaScript (Pascal, TypeScript, many others) I am honestly confused, and struggling to understand how this language and framework fits into my world - I have heard so many great things about Rails, but I am strongly getting the impression that most developers rely on learning conventions and memorizing run-time generated APIs?

 

I have an excellent capacity for learning, but I have a pretty limited capacity for memorization - in my daily PHP work I strongly rely on documenting thoroughly with annotations and writing code that passes all of PhpStorm's inspections. But in PHP frameworks, there are not generally a lot of run-time generated methods, and type-hints are availabel at least for arguments, so it is not generally much of a burden to have to document to get code that passes all inspections. It seems like this would be much more of a burden in Ruby, and particularly with Rails, where so many methods are generated at run-time.

 

I'm not about to embrace the philosophy that annotations are not necessary or that you don't need an IDE - two things I keep hearing and reading a lot.

 

What are the odds I will eventually find myself at home with Ruby, Rails and RubyMine?

Dennis Ushakov JetBrains 410 posts since
Sep 10, 2008

Hi Rasmus,

 

if nothing is working it may be a configuration problem of some sort, because autocompletion work fine for given example:

http://f.cl.ly/items/0n1H461l2z33010m2K0g/Screen%20Shot%202013-09-28%20at%2000.41.25.png

Do you have correct SDK selected in Settings | Ruby SDK and Gems?

Is your project recognized as Rails one (you can check this by clicking on the combo box in the project view, it should contain Rails item)?

Oleg Sukhodolsky JetBrains 871 posts since
Apr 4, 2012

I'd double check if the only sdk you have is selected for the project (check status of "Apply" button) because our UI in this area used to be not very informative

Also if you want to use jruby in 2.0 mode I'd suggest to try our EAP build (http://confluence.jetbrains.com/display/RUBYDEV/RubyMine+EAP) since this is implemented in it.

 

Regards, Oleg.

Dennis Ushakov JetBrains 410 posts since
Sep 10, 2008

Can you please attach output of Tools | Show Gem Environment?

Dennis Ushakov JetBrains 410 posts since
Sep 10, 2008

Can you create new rails project (File | New project) with same SDK and see if it suffers from the same problem?

More Like This

  • Retrieving data ...