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?

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?

Comment actions Permalink

Hi Rasmus,

if nothing is working it may be a configuration problem of some sort, because autocompletion work fine for given example:
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)?

Comment actions Permalink

The only option in the SDK dropdown is "jruby-1.7.4-p0 (C:\jruby-1.7.4\bin\jruby.exe) [1.9]" - and that is the only Ruby environment on my system.

My only choices for "language level" are 1.8 and 1.9 - I'm using JRuby 1.7.4 (2.0.0) with 2.0 configured as the system default (JRUBY_OPTS = --2.0) but RubyMine only offers 1.8 and 1.9 in the dropdown.

My selected run/debug configuration has the Rails logo on it.

Comment actions Permalink

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 ( since this is implemented in it.

Regards, Oleg.

Comment actions Permalink

Installed the EAP and was able to select Ruby 2.0 SDK from the dropdown.

Auto-completion is the same as before though...

Comment actions Permalink

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

Comment actions Permalink

Here goes:

RUBYGEMS VERSION: 1.8.24 RUBY VERSION: 2.0.0 (2013-05-16 patchlevel 0) [java] INSTALLATION DIRECTORY: C:/jruby-1.7.4/lib/ruby/gems/shared RUBY EXECUTABLE: C:/jruby-1.7.4/bin/jruby.exe EXECUTABLE DIRECTORY: C:/jruby-1.7.4/bin RUBYGEMS PLATFORMS:   ruby   universal-java-1.7 GEM PATHS:    C:/jruby-1.7.4/lib/ruby/gems/shared    C:/Users/Rasmus/.gem/jruby/1.9 GEM CONFIGURATION:    :update_sources => true    :verbose => true    :benchmark => false    :backtrace => false    :bulk_threshold => 1000    "install" => "--no-rdoc --no-ri --env-shebang"    "update" => "--no-rdoc --no-ri --env-shebang" REMOTE SOURCES: ---------------------- IDE: RubyMine (Momiji) RM-132.104, build #RM-132.104 OS: Windows 8 6.2[x86] Java: 1.7.0_10-b18 RubyMine SDK Environment: Sdk: jruby-1.7.4-p0 Sdk Version: ver.1.7.4 (2.0.0) 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_25-b17 p0 Ruby Interpreter: C:/jruby-1.7.4/bin/jruby.exe RVM Sdk: no Sdk Language Level: 2.0 Sdk Load Path:      C:/Program Files (x86)/JetBrains/RubyMine 132.104/rubystubs20      C:/jruby-1.7.4/lib/ruby/shared      C:/jruby-1.7.4/lib/ruby/2.0      C:/jruby-1.7.4/lib/ruby/1.9      C:/jruby-1.7.4/lib/jruby.jar!/jruby      C:/Program Files (x86)/JetBrains/RubyMine 132.104/rubystubs20 Sdk Gem paths:      C:/jruby-1.7.4/lib/ruby/gems/shared/gems      C:/Users/Rasmus/.gem/jruby/1.9/gems      C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems      C:/Users/Rasmus/.gem/jruby/1.9/bundler/gems Gems used for 'sandbank':      execjs (2.0.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/execjs-2.0.1      childprocess (0.3.9)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/childprocess-0.3.9      celluloid (0.15.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/celluloid-0.15.1      carrierwave (0.9.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/carrierwave-0.9.0      rest-client (1.6.7)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rest-client-1.6.7      turbolinks (1.3.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/turbolinks-1.3.0      andand (1.3.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/andand-1.3.3      polyglot (0.3.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/polyglot-0.3.3      thor (0.18.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/thor-0.18.1      mail (2.5.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/mail-2.5.4      omniauth-facebook (1.4.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/omniauth-facebook-1.4.1      sprockets (2.2.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/sprockets-2.2.2      temple (0.6.6)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/temple-0.6.6      minitest-spec-context (0.0.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-spec-context-0.0.3      secure_headers (1.0.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/secure_headers-1.0.0      omniauth-oauth2 (1.1.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/omniauth-oauth2-1.1.1      closure-compiler (1.1.10)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/closure-compiler-1.1.10      simple_form (2.1.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/simple_form-2.1.0      database_cleaner (1.1.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/database_cleaner-1.1.1      arel (3.0.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/arel-3.0.2      formatador (0.2.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/formatador-0.2.4      actionpack (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/actionpack-3.2.13      spork-minitest (0.0.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/spork-minitest-0.0.3      addressable (2.3.5)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/addressable-2.3.5      lumberjack (1.0.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/lumberjack-1.0.4      warden (1.2.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/warden-1.2.3      minitest (5.0.8)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-5.0.8      guard-spork (1.5.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/guard-spork-bb25f86a394e      fakeweb (1.3.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/fakeweb-1.3.0      bcrypt-ruby (3.1.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/bcrypt-ruby-3.1.2-java      heroku-api (0.3.15)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/heroku-api-0.3.15      multipart-post (1.2.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/multipart-post-1.2.0      coderay (1.0.9)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/coderay-1.0.9      rake (10.1.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rake-10.1.0      multi_json (1.8.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/multi_json-1.8.0      sass (3.2.10)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/sass-3.2.10      hike (1.2.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/hike-1.2.3      guard-minitest (1.3.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/guard-minitest-9f16f3ea4212      rb-fsevent (0.9.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rb-fsevent-0.9.3      faker (1.2.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/faker-1.2.0      coffee-script (2.2.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/coffee-script-2.2.0      inherited_resources (1.4.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/inherited_resources-1.4.0      activesupport (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/activesupport-3.2.13      kaminari (0.14.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/kaminari-0.14.1      guard (2.0.0.pre.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/guard-cd34f9e0264d      ffi (1.9.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/ffi-1.9.0-java      netrc (0.7.7)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/netrc-0.7.7      mime-types (1.25)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/mime-types-1.25      rack-ssl (1.3.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-ssl-1.3.3      sdoc (0.3.20)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/sdoc-0.3.20      activerecord (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/activerecord-3.2.13      tzinfo (0.3.37)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/tzinfo-0.3.37      slop (3.4.6)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/slop-3.4.6      builder (3.0.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/builder-3.0.4      rdoc (3.12.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rdoc-3.12.2      responders (0.9.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/responders-0.9.3      excon (0.25.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/excon-0.25.3      erubis (2.7.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/erubis-2.7.0      jwt (0.1.8)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/jwt-0.1.8      brwsr (1.1.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/brwsr-1.1.1      oauth2 (0.8.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/oauth2-0.8.1      coffee-script-source (1.6.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/coffee-script-source-1.6.3      coffee-rails (3.2.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/coffee-rails-3.2.2      httpauth (0.2.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/httpauth-0.2.0      turn (0.9.6)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/turn-0.9.6      strong_parameters (0.2.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/strong_parameters-0.2.1      sass-rails (3.2.6)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/sass-rails-3.2.6      heroku (2.41.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/heroku-2.41.0      activeresource (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/activeresource-3.2.13      launchy (2.3.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/launchy-2.3.0      railties (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/railties-3.2.13      devise (3.0.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/devise-3.0.3      rails (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rails-3.2.13      devise_invitable (1.2.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/devise_invitable-1.2.1      polyamorous (0.6.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/polyamorous-0.6.4      wkhtmltopdf-binary (          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/wkhtmltopdf-binary-      treetop (1.4.15)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/treetop-1.4.15      rb-inotify (0.9.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rb-inotify-0.9.2      activerecord-jdbc-adapter (1.3.2.DEV)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-76f4fb21164a      timeliness (0.3.7)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/timeliness-0.3.7      has_scope (0.5.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/has_scope-0.5.1      rack (1.4.5)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.4.5      pry (          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-      jquery-rails (3.0.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/jquery-rails-3.0.4      secretive (0.0.9)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/secretive-0.0.9      actionmailer (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/actionmailer-3.2.13      hashie (2.0.5)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/hashie-2.0.5      ansi (1.4.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/ansi-1.4.3      foreigner (1.5.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/foreigner-1.5.0      tilt (1.4.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/tilt-1.4.1      rack-test (0.6.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-test-0.6.2      method_source (0.8.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/method_source-0.8.2      slim (2.0.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/slim-2.0.1      cancan (1.6.10)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/cancan-1.6.10      faraday (0.8.8)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/faraday-0.8.8      json (1.8.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/json-1.8.0-java      gem_bench (0.0.6)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/gem_bench-0.0.6      i18n (0.6.1)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/i18n-0.6.1      jdbc-postgres (9.2.1002)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/jdbc-postgres-9.2.1002      activerecord-jdbcpostgresql-adapter (1.3.2.DEV)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/activerecord-jdbc-adapter-76f4fb21164a/activerecord-jdbcpostgresql-adapter      wicked_pdf (0.9.7)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/wicked_pdf-0.9.7      rubyzip (1.0.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rubyzip-1.0.0      timers (1.1.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/timers-1.1.0      journey (1.0.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/journey-1.0.4      jbuilder (1.0.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/jbuilder-1.0.2      rack-cache (1.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-cache-1.2      omniauth (1.1.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/omniauth-1.1.4      orm_adapter (0.4.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/orm_adapter-0.4.0      ransack (0.7.3)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/ransack-ed0060d885be      spoon (0.0.4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/spoon-0.0.4      listen (2.0.0.beta.2)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/listen-2.0.0.beta.2      activemodel (3.2.13)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/activemodel-3.2.13      spork (1.0.0rc4)          C:/jruby-1.7.4/lib/ruby/gems/shared/gems/spork-1.0.0rc4      spork-rails (4.0.0)          C:/jruby-1.7.4/lib/ruby/gems/shared/bundler/gems/spork-rails-0dd45e59d323

Is Rails 4 supported? I know it's only just out of beta...

Comment actions Permalink

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

Comment actions Permalink

Just did that, and you're right, there's no problem now - I put in a dummy controller, and "request." autocompletes just fine inside a controller/action-method.

One thing I noticed, is when I CTRL-click on "ApplicationController" in the sample Rails project, it finds two implementations - the one in "app/controllers", and one from "getting_started" in the "railties" gem.

When I CTRL-click on "ApplicationController" in the other project, I see two occurrences of each of those...

I'm still new to Rails, so I don't have much of a clue what could cause that, but I will talk to the lead developer on this project this morning and try to figure it out - I will let you know what we find.

Thanks for your input so far!

Comment actions Permalink

Okay, I looked into it with the lead developer - we have no idea why this doesn't work.

Comparing things like Project Structure (tests and excluded folders) and Load Paths and Scopes (empty in both projects) we don't see a difference.

Note that I have two versions of Rails installed, 4.0.0.rc1 and 3.2.13 - my dummy project uses 4.0.0.rc1 and the other project uses 3.2.13. Could that mean something?

I could post my Gemfile, which is very different from the one in the dummy project, if you think that could be it?


Please sign in to leave a comment.