Rails on Maui

Programming in Paradise

Favorite RubyMine Tips

See parent page RubyMine Tips for a summary of articles on RubyMine. Note, this article was published in May of 2013, so I’ve changed a couple ways that I do things, namely switching from Spork to Zeus.

Here’s a video of my favorite RubyMine tips with details below.

Favorite things to show about RubyMine

Here’s my notes when making the video.

  • Goto Last Edit Quickly go to the last places you edited
  • Git view of files and git aware of your changes
    • Next and previous diffs in file including view of the diff
    • Excellent diffing tool that has full editing capability
    • Commit dialog is absolutely fabulous Love how you can scroll through files and see diffs below, and even hit Cmd-D to go to diff screen to make little change.
    • Annotate! see who last changed a line.
  • Go to
    • Definition (of method or even a CSS file)
    • Method (ctrl-F12)
    • File and then hit the same key (cmd-;) to search non-project files
    • Recent File
    • Recent Edited Files
    • filtering by wildcards!
    • test file (and source file) (cmd shift t)
    • related files (cmd-ctrl ; )
      • On the haml file, I hit cmd-ctrl ; and I can go instantly to the controller. This ROCKS.
    • Click on icon to left of method in controller and go to view, or get asked to create it!
  • Template expansion, such as ‘desc’ cmd-T
  • Find box
    • incremental and highlights all matches
    • amazing display of regexp matches and replaces
  • Context sensitive ruby doc and completion
  • Find Usages of a method, variable, or class
  • Refactoring, such as changing the name of a method
    • Renaming an ActiveRecord class even creates the database migration!
    • Supports refactoring partials
  • Excellent syntax highlighting, with immediate error recognition
  • Ability to use Vim or Emacs or TextMate or OS X key bindings, besides the old school IDE defaults, and the ability to customize the keystrokes, even with 2 keystroke bindings (emacs style ctrl-x b)
    • Tooltips show you your customizations!
  • Switch from class to test (user.rb to user_spec.rb)
  • Expand Selection by Context
  • Find/Replace in Path
    • Can specify many different scopes including changed files, open files, etc.
    • Super fast – easiest way to find specific code needed
    • Example: Find sass import for “_foobar.scss” => search for regexp “import.*”
  • Rake db:migrate:redo displays a dropdown list of the migrations. Sweet!
  • Intention settings! Hit Opt-Enter and get cool options!
    • Convert do block to {} and vice versa
    • Convert js or ruby conditional to tertiary operator
  • Code inspections
    • Never had much luck with Java ones, but the Ruby ones Rock!
    • Can easily “polish” code to a coding convention, such as consistent use of when and when not to use parentheses for if statements (only when doing assignment inside of an if statement)
  • Preferences
    • If you’re using ideaVIM, it’s a very good idea to see if you like the option “Editor–>Refactorings–>Enable in-place mode”. You can hit the refactoring key quickly twice to get to the dialog way of typing in the variable. Personally, this way makes much more sense than the in-place editing.
  • Debugging
    • Easy configuration
    • conditional debugging and break when another breakpoint is hit.

What didn’t work for me

  1. Running spork inside of RubyMine. Instead, I use Guard/Growl and be sure to use different ports and databases so as not to interfere with RubyMine Debugging.


  1. Using the Mac OS-X+ keymap for this screencast. I personally use Vim bindings. Brief overview of Rails Tutorial, which is where the code example comes from.
  2. Goto File, Open up User Model (user.rb). Explain highlighting, beyond just syntax highlighting. user.rb
  3. Navigate –> File Structure to directly access methods using Cmd-F12
  4. Goto File (user_spec), showing how to type u_s
  5. Goto Test, go back to main class (Cmd-Shift-T)
  6. Hide Project Window and other parts to get more screen real estate
  7. Hide Navigation Bar
  8. Split Screen (Right click tab)
  9. Move to opposite group (Right click tab)
  10. Move between panes (Ctrl-Tab), and shows the switcher if you hold
  11. Show how to fix mapping of switcher in preferences.
  12. Change Splitter Orientation (Right click tab)
  13. Run tests
    1. All in file – right click at top and run (you can use the command to run all tests, but I never do that, as I just remember the context command)
    2. Specific Tests. Click on file to context, Ctrl-Shift-R
    3. Click on any context to run whichever tests you like.
  14. Comment out has_secure_password in user.rb, using Cmd-/
  15. Re-run tests
  16. Show Errors
  17. Git Integration
    1. Show how one can see what changed in Changes View, and do diff of user.rb
  18. Show other file navigation and reasons to use them:
    1. Instead of switcher, I use:
      1. View –> Recent Changed Files (Cmd-Shift-E)
      2. View –> Recent Files (Cmd-E)
    2. Often use Navigate –> Last Edit Location (Cmd-Shift-Backspace)
  19. Formatting
    1. Select lines and tab/shift-tab
    2. Code –> Reformat Code (Cmd-Opt-L)
      1. You may want to only fix the lines you’ve already changed
      2. Show configuration dialog Code Style => Ruby
        1. Mention “Align right parts of assignments or hashes” as something that may or may not be desirable
    3. Code –> Auto Indent Lines (Ctrl-Opt-I)
      1. Very useful to do this all the time
  20. Show failing tests in user_pages_spec.
    1. Start application within RubyMine using toolbar
    2. Login to application as example@railstutorial.org/foobar
    3. Go to Users tab and show users are missing
  21. Missing code in users/index.html:
    <ul class="users">
      <%= render @users %>

    Show editor features of typing erb code.

Keyboard shortcuts not in the video that I use all the time

  • Cmd-F12: hide/show tool windows
  • Vim: zz/Z top/bottom of page
  • Running/debugging rake tasks (Ctrl-Opt-R)
  • Goto definition! (Cmd-.)
  • Example of using a vim macro to prepend a method call to several assignment statements.
  • Find/replace that shows regexp evaluation results as they are developed
  • To search replace end of line
    • match: \n
    • replace: <new text>\n


Rubymine has an awesome configuration system. I was asked how to configure the method separators.

  1. Hit Cmd-, to bring up the preferences dialog.
  2. To find a setting, type in a keyword. I typed in “method”.
  3. Click on the matches. The matches for the keyword are highlighted.

Debugging a Rake Task in RubyMine

If you tried to set a breakpoint in a Rakefile and then right click and debug “filename” for a Rakefile, it doesn’t work. You will probably get an error:

Uncaught exception: undefined method `namespace' for main:Object

The trick is to first run the rake task normally (Tools -> Run Rake Task), and then the rake command will be in your run menu in the toolbar. Then hit the debugger icon next to it. Of course, you have already set a breakpoint in the rake test you wish to debug.