RubyMine Quick Start Guide

Welcome to RubyMine! This Quick Start Guide is designed to introduce key concepts and help you learn about the basic features of RubyMine. Buckle up!



Step 0. Getting Started

Before you start

Depending on your platform, you can use MRI Ruby, JRuby, MacRuby, Rubinius, IronRuby, or MagLev.

We recommend RubyInstaller for Windows and RVM for Mac OS X or Linux.

Make sure a Ruby interpreter is downloaded and installed on your computer. If not, please follow these download and installation instructions.

RubyMine supports Ruby versions 1.8.6 to 2.1.

You will also need RubyGems to extend the functionality of your applications.
Both RubyInstaller and RVM have RubyGems bundled.

Initial configuration

When you first run RubyMine, you are prompted to choose your preferred color and keymap schemes. You can choose whether to work in a light Default color theme or in a dark Darcula theme. If you are used to working with TextMate, Emacs, NetBeans, or Eclipse, you can just select your favorite scheme for a shorter learning curve:

In this quick start guide, we use the default keymap scheme. If you choose a different scheme, keep in mind that key mappings may be different or even unavailable for some commands. Read more about keymap configuration.

Initial settings

Of course you can change these settings any time you want.

There is also the IdeaVim plugin for RubyMine that provides vi/vim/gvim emulation. Please follow these instructions to install it.

to the top


Step 1. Create/Open Your Application

Quick start

Let's start from the very beginning. You may want to create a new application from scratch or to continue with an existing one. Either way, RubyMine's Welcome Screen gives you a quick start.

Create new application

To create a new application choose Create New Project or go to File | New Project... in the main menu. Enter project name and select its type — for example, Rails application:

You can also choose another Project type and create Gem application, RubyMotion application, or others.

Create new application

Now choose the Ruby interpreter, Rails version, Rails template, JavaScript library, and database to be used for your application:

If you have no Rails installed or want to upgrade, just choose Install Rails Gem... in Rails Version field to have RubyMine install it for you.

Install Rails

New application settings

When you are finished with these settings, RubyMine runs the Rails app generator and displays the results in the console:

New application result console

Open existing application

If you want to continue developing an existing application choose Open Directory or go to File | Open ... in the main menu. Find the folder that contains your project source code, select it and open:

If you already have any application opened, RubyMine will ask if you want to open the project in a new window or not. So you can have several applications opened in different windows. You can also work with several applications in one window.

Open an existing application

You can set up VCS behavior or even break your application down into smaller chunks, and place virtually every directory under its own version control system.

To check out your application directly from a version control system choose Check out from Version Control or go to VCS | Check out from Version Control in the main menu. Choose VCS (GitHub, CVS, Git, Mercurial, Subversion, or Perforce) and fill in the right paths:

Clone VCS repository

to the top


Step 2. Customize Your Environment

Working in an IDE means living in it, so you'll want to make your environment as comfortable as possible for your eyes and fingers. In RubyMine, you can configure the set of keyboard shortcuts (keymap), customize scrolling behavior, highlighting, backgrounds, fonts, and more.

Set up the IDE look

Let's start with the general "look and feel" of the IDE. Please go to File | Settings...RubyMine | Preferences..., find Appearance page, click the Theme drop-down list and select a scheme you prefer — the light one:

Click the icon on the main toolbar to open the Settings window.

Use the Search field in the top left corner to find any specific configuration setting.

Learn more about the Appearance settings page.

Look and feel settings

Or the dark one:

Look and feel settings

Customize the editor

The IDE Settings - Editor section contains many pages helping you to customize every aspect of the editor's behavior.

RubyMine comes with several pre-defined light and dark color schemes that you can find under Colors & Fonts. Choose one or just save any scheme as your own and personalize the background, font, colors of syntactical elements, error highlighting, etc. The effects of all settings are immediately shown in the preview pane:

If none of the predefined schemes suits you, you can either customize your own or check out the custom themes created by the community.

Change color theme

Configure keymap
Change keymap scheme

The set of keyboard shortcuts you work with, is one of your most intimate habits. Your fingers "remember" certain combinations of keys so changing this habit can be rather painful. With this in mind, RubyMine supplies you with a wide range of predefined keymaps that you can choose on the IDE Settings - Keymap page:

Keymap settings

Again, you can create your very own keymap based on an existing one. Note that you can search through a keymap by command name or key strokes to easily change the settings.

Quick switch scheme

In fact, there is no need to open the Settings window whenever you want to change a defined color scheme, keymap, or L&F scheme. You can simply use the Ctrl+BackQuote(`)shortcut instead.

to the top


Step 3. Manage Gems

There‘s no getting around using Ruby gems in your projects. RubyMine simplifies working with gems in two different ways. First, you can manage project gems manually with the help of special UI that allows installing and updating gems. Second, RubyMine automatically analyses all gems dependencies and helps you install the missing ones.

Install and update gems

You can always use console (View | Tool Windows | Terminal) if you prefer to manage gems manually: Terminal

You can also add and set up a remote SDK.

Learn more about the Ruby SDK and Gems settings page.

To manage your gems go to Project Settings - Ruby SDK and Gems page where you can find all the gems installed for a selected SDK:

Ruby SDK and gems settings

The and buttons allow you to add and remove Ruby interpreters available in a project. The and buttons will forward you to the list of all gems available under the specified repositories ( rubyforge.org by default) where you can search for a gem to install or update.

Please also take a look at Gem Dependency Diagram to get a view on all project gems and their dependencies.

Bundler support

If there is no Gemfile, RubyMine automatically detects any missing gems by scanning for all Ruby gems calls on project open, and shows a notification.

Read more about gems management in RubyMine.

If you use Bundler, you’ll be glad to know that RubyMine loads requirements from a Gemfile and manages all the dependencies accordingly. If you have a gem in your Gemfile that is missing, RubyMine offers to install it:

Missing gems inspection

You can also invoke any Bundler command directly from the IDE using Tools | Bundler any time you need.

to the top


Step 4. Populate Application

Add new file

Adding new files, directories, or Rails elements to your project is just a snap: select File | New... from the main menu or New from the context menu of the Project Tool Window.

Select the element of your choice and enter its name. RubyMine does the rest: creates files by templates with some initial source code, or runs the selected generator in the console, and produces the complete structure of files and directories.

For Rails applications you can select Tools | Run Rails Generator... or press Ctrl+Alt+G⌥G to create a model, controller, scaffold, and much more:

Rails generator

to the top


Step 5. Run and Debug Your Application

Ruby on Rails is all about getting a working application as early as possible. So don't wait to run your app. You may need to run or debug a Ruby or Rails script, a Rake task, or a test scenario. In all these cases, you need a special profile, or a run/debug configuration, which defines the script name, working directory, environment variables, and other vital execution configurations.

Default run/debug configurations

For each element that can be run/debug, there is a default profile. You can easily launch such an element from its context menu, or with a handy shortcut: Ctrl+Shift+F10⌘⌥F8.

Running

To run your application choose one of the default profiles from a list on the tool bar and run it by clicking the icon or by pressing Shift+F10⌘⌃F8.

Run your applcation

...and view the results:

Running results

Any time you run a new Rake task, Ruby file, Rails script, etc. RubyMine creates a run/debug configuration based on a default one. You can manage your configurations in Run | Edit Configurations....

In addition, RubyMine suggests an advanced way to find a Rake task and run it. Select Tools | Run Rake Task... or press Ctrl+Alt+R⌥R:

Run a Rake task

If you prefer consoles, you can launch the IRB console (Tools | Run IRB Console...) or the Rails console (Tools | Run Rails Console...) and work there as usual, without leaving the IDE.

Debugging

Debugging in RubyMine does not require any additional gems. However, if there is debugger gem in your Gemfile, debugger-xml gem should also be present.

Launching a debugging session is as simple as running your app: use the context menu or select a suitable run/debug configuration and click the icon or pressShift+F9⌘⌃⇧F8.

To find out what is wrong with your code, simply set a breakpoint by clicking the left side bar near the code line. Execution stops there, and you can analyze variables and run your code step by step. Just place the caret on a variable to see its current value. Then use F8⌥F10 to step over or F7⌥F9 to step into your code:

To view and manage all project breakpoints go to the context menu of a breakpoint, choose View Breakpoints... or press Ctrl+Shift+F8⌥⇧F7.

Set a breakpoint

The ultimate way to add a code expression to Watches is to select it, go to the context menu and choose Add to Watches.

The Debug Tool Window shows everything you need: threads, variables and expressions added to Watches:

Debugging UI window

You can also select run/debug configuration from a list and immediately launch it with Alt+Shift+F10⌘F8 shortcut.

RubyMine has a lot of running and debugging options. For example, you can run and debug your JavaScript files. CoffeeScript support includes debugging as well. You can also debug in console or remotely.

to the top


Step 6. Find Your Way Through

Now when you know how to start working with, populate and run your project, it’s time to look at RubyMine navigation features. They will help you not to get lost and will also increase your productivity.

Search everywhere

Searching is for sure the most familiar and necessary option that is used for quick navigation. With RubyMine you can search for any class, file, action or even an IDE setting with the only one action. Use the Toolbar icon on the top right to search everywhere:

Search for a class

Search for project elements

The essential tool for project elements overview is the View | Tool Windows | Project tool window. It shows your project as a tree of files and directories. To access it, click the tool windows bar icon or press Alt+1⌘1:

Just start typing in any tool window and see how the matching nodes are highlighted. For example, you can use this method to search for a file in the Project Tool Window.

Project tool window

You can search in all navigation popups by using the asterisk wildcard; use all caps for CamelHumps; use spaces for snake_case names; use slashes for nested folders; and so on and so forth.

First of all to quickly find an element by name and open it in the editor, use the navigation popups: press Ctrl+N⌘N (for a class), Ctrl+Shift+N⇧⌘N (for a file), or Ctrl+Shift+Alt+N⌥⇧⌘N (for a symbol), and start typing the name you are looking for:

Search for a class

Navigation bar

Navigation Bar (Navigate | Jump to Navigation Bar) is a good alternative to the Project Tool Window. Press Alt+Home⌥↖ to quickly open it.

Search for code elements

The basic way to navigate and search your source code is Ctrl+F⌘F command. Start typing your search string, and get to its occurrences in the current file:

RubyMine also helps you to look for a certain string within a directory, any arbitrary scope, or an entire project: press Ctrl+Shift+F⇧⌘F.

Search in file

The ultimate way to navigate around the current file is to use the File Structure View (Alt+7⌘7) and search through it:

Ruby file structure view
Haml file structure view


Place the caret on any method or symbol, and all the usages of it in the current file will be highlighted.

You can find all the usages of a code element in the whole project or directory by using the Find Usages option (Alt+F7⌥F7):

Find usages

Use "Go to" actions to navigate to a declaration (Ctrl+B⌘B), implementations (Alt+Ctrl+B⌥⌘B), type declaration (Shift+Ctrl+B⇧⌘B), or super method (Ctrl+U⌘U).

Rails-specific navigation

The main tool for working with projects is the Project Tool Window. However, if you are working with a Rails application, you might find it more convenient to switch to Rails View. It shows the logical project structure, with its controllers, models, views, or migrations. To switch to the Rails View, click the drop-down list at the top of the tool window and choose Rails:

Rails project view

The "Go to view" gutter near the controller action will offer to create the view if it doesn't exist yet.

RubyMine also suggests special icons in the left gutter of the editor: for example, will navigate from an action to a corresponding view, while will navigate to a controller action from its view:

Go to view and to action

Go to related files

To quickly navigate between the appropriate Rails components such as model, controller, view, helper, unit/functional/spec test from any location, use Navigate | Related File... (Alt+Shift+N⌘⌥↖).

Do not miss the Model Dependency Diagram (go to Diagrams in the context menu) to get a bird's view of all project models with their attributes and associations. You can quickly navigate from the diagram to a model or association, and even do some refactoring:

Model Dependency Diagram

IDE components
Find any action in the IDE

There are many ways to navigate across the IDE. You may not remember all the actions and menu commands the first time around, and that’s OK. Don't worry! Any time you need any IDE action, you can find in Help | Find Action... (Ctrl+Shift+A⌘⇧A). So, let’s briefly outline some of the main commands.

Switcher

We will start with the Switcher: press Ctrl+Tab⌃⇥ to show the list of all tool windows and open files, and then, keeping the Ctrlkey pressed, use Tab or arrow keys to scroll to the component you want to go to.

Press Ctrl+E⌘E to see the list of recent files. Press Ctrl+Shift+E⌘⇧E to see the list of recently edited ones.

If you have several IDE windows opened, use the Ctrl+Alt+[⌥⌘[ and Ctrl+Alt+]⌥⌘] shortcuts to switch between them.


If you select a file in one of the IDE components and want to view it in another one (the editor, Project/Rails view, Navigation bar, or a changelist), then use the Select Target (Navigate | Select In... or Alt+F1⌥F1).

Finally, pressing Esc will bring you back to the editor, wherever you are. Shift+Esc⇧⎋ will hide all tool windows and leave only the editor.

to the top


Step 7. Code with Smart Assistance

RubyMine is famous for its smart code analysis features. Whatever you do to develop your source code, it is always at hand, helping you to create error-free applications with no time wasted.

Edit and write code

At every stage of development, in any files, try to use code completion (Ctrl+Space⌃␣), which takes into account the current context. Depending on where you invoke this action, you can complete keywords or code blocks, infer types, create chained queries, and more:

Quick documentation (Ctrl+Q⌃J) can be used not only in the editor but in the code completion pop-up as well.

Code completion

Enjoy live templates/code snippets (Ctrl+J⌘J) or surround templates (Ctrl+Alt+J⌥⌘J) to produce entire code constructs:

Click the icon or go to Settings - Live Templates to edit the default snippets or add your own.

Code live templates

RubyMine helps you to follow code style guides. All the new code is formatted automatically according to IDE settings (Settings - Code Style). Nevertheless you may need to format some party code or to apply changes made in code style settings. To do that, use Code | Reformat Code... (Ctrl+Alt+L⌥⌘L).

You can select successively increasing code blocks by pressing (Ctrl+W⌃W) or decrease the current selection by pressing (Ctrl+Shift+W⌃⇧W).

Inspect your code

We developers spend only 20% of our time writing new code, but up to 80% improving existing code. To help you avoid errors and correct them faster, RubyMine gives you numerous hints and prompts based on best development practices.

Mind the marker bar on the right as you code. Red colored stripes denote errors, yellow stripes are warnings, and blue stripes stand for TODOs. Simply click them to navigate to the error, warning or TODO. A summary of the inspection results for the current file is shown in the colored indicator on top. Make it green! File inspections status

First of all, like a diligent pair programmer, RubyMine keeps a close eye on what you are currently doing. The IDE highlights any errors as you type. Place the caret at an error location and you will see a tooltip with its description:

Errors highlighting

Moreover, the IDE comes up with smart suggestions, also called intention actions, which are marked with the icon. Click it or press Alt+Enter⌥↩ to auto-create a new method that you have not yet declared; perform i18n for a string value; fix an if/else statement; and much more:

Quick fix option

Sometimes you need to look deeper into your code and inspect the whole project or its part. Run Code | Inspect Code and explore the results:

Code inspection results

You can use the Hector The Inspector Icon icon in the bottom right corner to configure inspections and set up the highlighting level for your files.

RubyMine comes with a wide range of predefined inspections. All of them have a description and can be switched on or off, or configured as necessary in the Setting-Inspections window:

Code inspection settings

To help you make your source code less tangled and more readable, RubyMine offers searching for duplicates in the whole project or its part (Code | Locate Duplicates...). Take a look at the detected repetitive fragments in the Duplicates Tool Window and decide what to do with them.

Refactor safely

After inspecting your code, you may be interested in code refactorings provided by RubyMine. The IDE helps you to rename safely; to extract methods, superclasses and modules; to introduce variables, constants, parameters; and more. Use Refactor | Refactor This... (Ctrl+Alt+Shift+T⌃F) to view all refactorings available for the current code fragment.

For example, let’s assume you’ve found some duplicate code in one of the project files:

Duplicates in Ruby code

To make this code DRY you should extract a variable first. Place the caret on a code element and press Ctrl+Alt+V⌘⌥V:

Extract variable

Extract variable

Now you can extract a method (Ctrl+Alt+M⌘⌥M):

Extract method

After extracting the method, a local variable is no longer needed, so you can inline it (Ctrl+Alt+N⌘⌥N):

Inline variable

Applying a few small changes to the new method code, we have:

You may also want to use Alt+Enter⌥↩ to convert if block to the ternary operator: Convert if block

Code refactoring results

All refactorings are aware of Rails "magic". For example, renaming an action method will rename the corresponding view template files; will update references to action method/view templates from rails calls such as render, redirect, etc.; and will rename the test file for the action's view.

If for some reason you want to rename your method, just place the caret on its name and press (Shift+F6⌥F6). RubyMine shows all the places that are to be changed and will perform all the changes for you:

Rename refactoring

to the top


Step 8. Create and Run Tests

When you decide which testing framework you want to use, install and attach the required gems. This will make context menu commands and code completion available to you.

It goes without saying that you need to write tests. Let’s just explore RubyMine’s testing support, which extends to all major frameworks: RSpec, Cucumber, Shoulda, MiniTest and Test::Unit.

Creating a test is as simple as creating any new file. Just go to File | New... and choose from a list of test templates, for example, RSpec Test Template:

New RSpec test

RubyMine allows launching all tests in a directory, test scripts or scenarios, and even individual test methods or examples. Go to the context menu of a test or directory, or create your own run/debug configuration.

Finally, view and work with the test results in the special test runner UI, which opens in a tab of the Run Tool Window:

Use the icon to filter test results and see only those that did not pass.

Use the icon to manage your tests, for example to set up an adjustable auto-test delay.

Test runner UI

to the top


That's about it!

Here we have given a very concise overview of some vital RubyMine facilities, just to give you a quick start. There are numerous important features that can help make your life easier as a developer and your source code nicer and cleaner. Try this basic functionality and then, when you’re ready, dig deeper with our tutorials and videos. Enjoy developing with RubyMine!

If you have any additional questions, you're welcome to post them on the RubyMine Discussion Forum and to read our blog from time to time.

If you are new to Ruby on Rails, we recommend this tutorial from David Loeffler. It shows you how to use RubyMine as your editor based on the popular Ruby on Rails Tutorial by Michael Hartl.

to the top