RubyMine Rails-specific Code Completion
November 26th, 2008 by Eugene ToporovAnd finally, the Rails! Rails is probably why most of us is using Ruby, right? So, RubyMine helps coding when Ruby on Rails is used.
Ruby on Rails Smartness #1
When a variable holds a model object RubyMine knows its type, its details and wisely offers the code completion.

And once you select first attribute to find_by you can try once again and RubyMine suggests again to create a complex find statement.

Ruby on Rails Smartness #2
Many Rails methods expect parameters of a certain kind or format. One example of such methods is validation methods (validate_uniqueness_of, validates_numericality_of, etc.).
RubyMine knows what should be in completion list after such methods, finds and suggests appropriate names.

Ruby on Rails Smartness #3
Quite often methods take hashes as parameters with only certain key values, ignoring the others.
class AdminController < ApplicationController
def logout
session[:user_id] = nil
flash[:notice] = "Logged out"
render :action => :index, :partial => 'bye'
end
def index
end
end
Some parameters of render hash in a controller are :partial, :action, :layout and :template.
When these are used the right part of the hash is clear.

For :partial it is partial view,

For :action — the action from the controller or its parent.

For other supported parameters check the documentation.
Tags: code completion, editing, rails
November 26th, 2008 at 4:52 pm
Hi,
Just wondering if you guys can link to the forums from this blog - I keep landing back here from my RSS feed and want to click into the forums but can’t.
Or am I missing the link?
Regards,
Nicholas F.
November 26th, 2008 at 5:34 pm
This is hot stuff. As a never-satisfied customer have you considered adding rails documentation to the hash keys and valid options? Hop on the steroids, RubyMine!
November 27th, 2008 at 4:57 am
Hello Stefan,
Sounds great!
I`ve create an issue on this: http://www.jetbrains.net/jira/browse/RUBY-2409
Regards,
Oleg
November 27th, 2008 at 4:59 am
@Nicholas F: A brilliant idea!
I added the links to the sidebar.
Thanks,
-Eugene