When I use the one in RubyMine I don't see autocompletion for helpers (like current_user, destroy_user_session_path, etc.). It's very bad :( Can someone help me? :)
2 Answers
Short answer:
You're not doing anything wrong. Right now, it's the best Rubymine can do.
Slightly longer answer:
As you probably know, Ruby can be a very dynamic language. Devise relies heavily on the metaprogramming capabilities of the language. The helpers, such as current_user
are generated at runtime, rendering Rubymine's static analysis capabilities ineffective.
Rubymine would need to have special support for Devise and, as far as I know, it just doesn't.

- 616
- 8
- 17
-
Maybe there's a possibility to provide some dummy methods somewhere to get type hinting and code completion without breaking the functionality of the methods?! – Sven R. Feb 17 '15 at 08:37
-
I'm using RubyMine for 4 years already, and I guess there are no possible solutions yet for this kind of problems. The only possible solution as I can see, RubyMine could use debugger to save all the application states with all the methods, and then use them while interpolation, but I don't think it will be done in the nearest future or ever. :) – Dmitry Polushkin Feb 17 '15 at 12:18
-
@sreuter As far as I know it's not possible, although it would be a cool feature. – Jorge Marques Feb 17 '15 at 17:17
-
2There is https://github.com/barryvdh/laravel-ide-helper for Laravel for dynamic methods, I'm wondering whey nobody have done somehting like this for Rails. – Vedmant Oct 14 '16 at 19:38
Even though it's obvious, you can put
def current_user
super
end
to your ApplicationController at least to avoid undefined method warning in all controllers. I had no success telling RubyMine to autocomplete using YARD:
# @return [User]
def current_user
super
end
Update: P.S. It is good idea to let other developers know about the reason why this method is needed, if used without YARD comment. Otherwise it will be removed or at least questioned by others.
Update 2019-02-26: Code navigation works at least in 2018.3.4 thanks to YARD comment

- 6,024
- 2
- 37
- 34
-
1Just tried this using yard with IntelliJ 15 and the autocomplete via yard worked for me! You can get autocomplete to work in views as well, by adding the same thing to ApplicationHelper. – xeorem Feb 23 '16 at 10:47