Quick Start Guide
In this section:
- Before you start
- Initial configuration
- Set defaults from the Welcome screen
- Work with projects
- Customize everything for your project!
- Background tasks
- Use macros
- Work with multiple files
- Find your way through
- Code with smart assistance
- Create and run tests
- That's about it!
Welcome to RubyMine! This short guide aims to help you get a grip on the IDE.
Before you start
Make sure that the following prerequisites are met:
- Ruby interpreter is downloaded and installed on your computer.
If not, follow these download and installation instructions .
RubyMine supports Ruby versions 1.8.6 to 2.3.
- You will also need RubyGems to extend the functionality of your applications. Both RubyInstaller and RVM have RubyGems bundled.
- RubyMine is downloaded and installed on your computer.
Note that the download page contains installation instructions for the various platforms; these instructions may vary for the different operating systems.
RubyMine is cross-platform and works on Windows, macOS, and Linux.
When you start RubyMine for the very first time, you are asked whether you have a previous version and what to do with the settings. For the purposes of this tutorial, assume that there is no previous version, and click OK:
Next, you get the RubyMine Licence Activation dialog, where you have to specify your particular license:
After you have specified your license, RubyMine shows the initial setup dialog. Here you have to select the keymap and themes of the IDE and editor you want to use. Refer to the section Running RubyMine for the First Time.
Note that RubyMine has several pre-defined keymaps: for those who like Eclipse or Visual Studio, for Emacs fans, GNOME, KDE, and more. Explore the list of available keymaps in the Keymap page of the Settings/Preferences dialog.
If later you decide that your initial choice of the keymap was wrong, you can always change your settings. To learn more about configuring the keymap, refer to the section Configuring Keyboard Shortcuts.
Set defaults from the Welcome screen
Again, if this is your very first start (or if you have no open project), you see the Welcome screen:
If you click Configure, RubyMine shows the drop-down list that suggests you to configure settings/preferences, plugins, import and export settings, and check for updates. Choose Settings/Preferences and see the Settings/Preferences dialog. Look at this dialog - it has the header Default Settings/Preferences.
What does it mean? These settings will be used every time you create a new project.
For example, you want all you newly created projects to use the same interpreter - OK, you can define such an interpreter in the Default Project settings:
Note that the interpreter settings relate to a default project.
The settings that pertain to a default project, are marked with the icon .
The Editor settings pertain to your working environment.
It is also possible to set your preferred font size for the editor - this is done in the Font page under the Colors and Fonts node in the Settings/Preferences dialog. Again, you have to create a copy of the scheme first, if you haven't done it yet, and then specify the desired font size for the editor. This font size will apply to the current editor tabs and to all the newly opened editors. However, it does not affect the font size of the IDE components.
Note that you can always see the results of your experiments in the Preview pane:
Change Settings/Preferences later
For example, you want to change Look and Feel (theme) of the IDE. Note that RubyMine comes with several pre-defined themes. The set of available themes depends on your platform. You can find the theme of your choice in the Appearance page of the Settings/Preferences dialog.
This is how you can change the IDE theme:
- On the main toolbar, click , or press Ctrl+Alt+S.
- Expand the Appearance and Behavior node, and click Appearance.
- On the Appearance page, select the theme you prefer from the drop-down list Theme:
Note the link Reset that appears on top of the dialog box - if you've changed your mind, click it to roll the changes back. Also note the button Apply that becomes enabled when you hover your mouse pointer over it:
You can also change the other settings that define the look and feel of your RubyMine, for example, the windows' behavior.
- Apply the changes. You might be suggested to restart the IDE (for example, when you change theme to or from Darcula).
Difference between the L&F theme and the color scheme of the editor
Mind the difference between the IDE theme (look&feel) and the color scheme of the editor. The former relates to the entire IDE, while the latter relates to the editor only. It is quite possible to have a dark theme for the IDE (for example, Darcula), and one of the light color schemes for the editor (for example, Default). So doing, all the RubyMine components will be rendered in one color scheme, and the editor pane in the different one:
Work with projects
Everything you do in RubyMine, you do within the context of a project.
In RubyMine, a project is a directory that contains source code, and a nested directory with the name
.idea. The directory
.idea is the place where RubyMine stores all the necessary information - it's not visible in the Project view. From the user's point of view, a project is just a directory that contains some Ruby code.
What is most interesting about RubyMine project management, is its ability to open multiple projects in one frame. When you create a new project (File | New Project), or open an existing one (File | Open), RubyMine suggests you to choose which way you want the project to be opened: in a new window, in the same window after closing the previously opened project, or added to the previously opened project.
You can have as many projects opened in one window as required. So doing, the first project is considered the primary project. All the symbols of the added projects are visible from the primary project.
Refer to the section Creating and managing projects for details.
As an exercise, create a new empty project, where you can develop some pure Ruby code. This case is discussed in detail in the tutorial Create and Run Your First Project .
By the way, RubyMine suggests creating projects of the various types: empty, Rails, Ruby Gem, RubyMotion application, Twitter Bootstrap, HTML5 Boilerplate, etc. You can explore the available types yourself, when creating a new project:
As you can see, RubyMine supports all the major Ruby-based frameworks. For each of the supported project types, RubyMine creates the corresponding file and directory structure, and all the necessary artifacts.
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, Welcome Screen gives you a quick start.
Create new application
When you are finished with these settings, RubyMine runs the Rails app generator and displays the results in the console:
Open existing application
To check out your application directly from a version control system, choose Check out from Version Control on the Welcome screen, or go to on the main menu. Choose VCS (GitHub, CVS, Git, Mercurial, Subversion, or Perforce) and fill in the right paths:
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
To manage your gems, go to the Ruby SDK and Gems page where you can find all the gems installed for a selected SDK:
The and buttons allow you to add and remove Ruby interpreters available in a project.
To install or update gems, write them to
Gemfile, and then they will be installed by the
Bundler. Alternatively, start the terminal and issue
gem install command. (The terminal may be both RubyMine's or system.)
Please also take a look at Gem Dependency Diagram to get a view on all project gems and their dependencies.
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:
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.
Refer to the sections Ruby Gems Support for details.
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.
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.
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 .
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.
...and view the results:
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 press Shift+F9 .
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 to step over or F7 to step into your code:
The Debug Tool Window shows everything you need: threads, variables and expressions added to Watches.
You can also select run/debug configuration from a list and immediately launch it with Shift+Alt+F10 shortcut.
Customize everything for your project!
Look at the main toolbar — there is a Settings button . Clicking this button opens the Settings/Preferences dialog box, where you can change your project structure, set up version control, and tweak your working environment to make the development process a real pleasure.
Some of the settings pertain to a particular project — for example, project interpreter, version control configuration, or file colors. They are marked . The others — like the Editor settings, keymaps, or live templates — pertain to your whole working environment, and thus can be configured even without an open project.
Ruby interpreter is vital — without it you will not be able to do anything...
In RubyMine, you can define several Ruby interpreters - they just comprise the list of interpreters, available on your machine. From among them, you can choose the one to be used in your project.
You need to tell RubyMine which Ruby interpreter you want to use since it can use a different interpreter for each project:
RubyMine will use this information for indexing.
Refer to the product documentation for details.
Surely, you keep your sources under a version control, right? Git? SVN? Mercurial? With RubyMine, it's easy to set up, and again the IDE does a good job auto-detecting the VCS already used for existing projects.
But you can fine-tune — just click Version Control node in the Settings/Preferences dialog. By default, you will see the project root directory only, but you can break your application down into smaller chunks, and place virtually every directory under its own version control system.
In the Settings/Preferences dialog, you can also define some behaviors that are common for all version control systems: confirmation on creating or deleting files, tasks performed in the background, ignoring unversioned files and more.
Refer to the sections under Version Control with RubyMine for details.
In addition to a traditional version control system, you can use local history. With Local History, RubyMine automatically tracks changes you make to the source code, results of refactoring, and state of the source code based on a set of predefined events (testing, deployment, commit or update). Local history is always enabled.
Your project might contain several sites, each one with its own set of files with the same names . When they are all opened in the editor, it's rather confusing... How can one tell which site they belong to? RubyMine helps make them stand out by painting their editor tabs ().
Break down your project into smaller chunks — scopes (for example, a scope per site), and select a color for each one.
Refer to the page Configuring Scopes and File Colors for details.
IDE and Editor
Working in an IDE actually means living in it, and it is quite natural to make your haunted place pleasant for your eyes and comfortable for your fingers. That's why RubyMine makes it possible to choose a look and feel for the IDE and the editor, configure your preferred set of keyboard shortcuts (keymap), fine-tune the scrolling behavior, highlighting, and more.
All these settings are (again) configured in the Settings/Preferences dialog: click to open this dialog, and see the list of pages. Here are three pages that might be of interest for the starter: Appearance, Editor, and Keymap.
Remember, you've initially selected the look and feel for your IDE on the first start? If you are not happy with the result, now it's time to change your mind. In the page Appearance page (Settings/Preferences | Appearance&Behavior | Appearance) you can select a "look and feel" of your RubyMine installation. Just click the Look and feel drop-down, and select the scheme that suits you better. You don't need to close the Settings/Preferences dialog to observe the results of your experiments: click Apply, see what happens, and close the dialog when you are quite happy with what you've got.
The whole bunch of pages under the Editor node of the Settings/Preferences dialog helps you tune every aspect of the editor's behavior. Note that RubyMine comes with the predefined color scheme, but if you want to make up something very personalized, you are welcome to do it: save the default scheme with a new name, and start changing its background, font, colors of syntactical elements, error highlighting, etc., and immediately observe the results in the preview pane.
The set of keyboard shortcuts you work with is one of your most intimate habits - your fingers "remember" certain combinations of keys, and changing this habit is rather painful. With this in mind, RubyMine supplies you with a wide range of pre-defined keymaps (Keymap), for those who prefer Eclipse, or for those who've had long experience with Visual Studio... You can create your very own keymap on the base of an existing one.
Finally, there is the magic shortcut Ctrl+Back Quote that helps you switch between schemes (all of them — keymaps, colors, code styles, and L&F) without the Settings dialog (for Windows and Linux users only).
Refer to the section Configuring Keyboard Shortcuts for details.
Though you can choose any keymap that corresponds to your preferred editor (Emacs, Vim, TextMate, etc.), you might still want to open files in your preferred editor. You can easily do it by configuring an external tool. For example, you might want to open a current file in Emacs as an external tool.
Sometimes, when a long task is in progress, RubyMine shows a Progress bar. You can bring such a task to the background, but still see how it goes on. Refer to page Working with Background Tasks for details.
It would be nice to have a chance to simplify your work with the editor. Using macros is just one of the possible ways. Refer to the product documentation for details.
Work with multiple files
As you might have noticed, RubyMine opens each file in a separate tab in the editor.
RubyMine provides a handy way to switch between the various tabs, allows pinning and unpinning each tab, placing editor tabs along any of the four borders of the window, splitting the editor tabs, and more.
Refer to the documentation section Managing Editor Tabs for details.
Find your way through
Now when you know how to start working with RubyMine, it’s time to look at its navigation features. They will help you not to get lost and will also increase your productivity.
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 only one action. Double-press Shift or click the magnifier glass icon in the upper-right corner of the RubyMine window:
Search for project elements
The essential tool for project elements overview is the 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:
To quickly find an element by name and open it in the editor, use the navigation pop-up: press Ctrl+N (for a class), Ctrl+Shift+N (for a file), or Ctrl+Shift+Alt+N (for a symbol), and start typing the name you are looking for. The list of matching names shrinks as you type, but this is just one of the handy facilities: you can use the asterisk wildcard, all caps for CamelHumps, or spaces for snake_case names, slashes for nested folders and so on, and so forth.
Search for code elements
The basic way to navigate and search your source code is Ctrl+F. Start typing your search string, and get to its occurrences in the current file:
The ultimate way to navigate around the current file is to use the File Structure View (Alt+7 or Ctrl+F12) and search through it:
Besides that, RubyMine suggests a more sophisticated approach, namely search for usages. For example, if you want to navigate from a symbol to one of its usages within your application, press Alt+F7, or choose on its context menu, and observe the results in the Find Tool Window:
Use "Go to" actions to navigate to a declaration (Ctrl+B), implementations (Ctrl+Alt+B), type declaration (Ctrl+Shift+B), or super method (Ctrl+U).
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:
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:
To quickly navigate between the appropriate Rails components such as model, controller, view, helper, unit/functional/spec test from any location, use (Ctrl+Alt+Home):
Do not miss the Model Dependency diagram (go to on 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:
Read more about diagrams in RubyMine in the section Working with Diagrams.
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 it in (Ctrl+Shift+A) or use Search Everywhere. So, let’s briefly outline some of the main commands.
Let's start with the switcher: press Ctrl+Tab to show the switcher, which is a list of the RubyMine's tool windows and open files, and then, keeping the Ctrl key pressed, use Tab or arrow keys to scroll to the component you want to go to:
Press Ctrl+E to see the list of recent files. Press Ctrl+Shift+E to see the list of recently edited ones.
If you have several IDE windows opened, use the Ctrl+Alt+Open Bracket and Ctrl+Alt+Close Bracket 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 view, Navigation bar, or a changelist), then use Select Target (Alt+F1):
Finally, pressing Escape will bring you back to the editor, wherever you are. Ctrl+Shift+F12 will hide all tool windows and leave only the editor.
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 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:
RubyMine comes with a wide range of ready-to-use live templates, or snippets, which you can explore in the Live Templates page of the Settings/Preferences dialog. If you see that you are lacking something especially important for your development goals, extend this set of snippets with your own ones.
RubyMine helps you follow code style guides. All the new code is formatted automatically according to the code style settings (Settings/Preferences | Editor | Code Style). Nevertheless you may need to format some part of the code or apply changes made in code style settings. To do that, use (Ctrl+Alt+L).
Analyze your code
We, developers, spend only 20% of our time writing new code, but up to 80% improving the existing code. To help you avoid errors and correct them faster, RubyMine gives you numerous hints and prompts based on the best development practices.
First, as you type, you immediately have all syntactical errors underlined with a red wavy line. If you place the caret at an error location, you will see a brief description of the problem at the tooltip, and also in the left side of the Status Bar. Besides that, you see red stripes along the validation bar, or the marker bar. If you hover your mouse pointer over such a stripe, you see the error description at the tooltip.
As you type your code, RubyMine, like a diligent pair programmer, keeps a close eye on what you are currently doing. Moreover, the IDE comes up with smart suggestions, also called intention actions, which are marked with the or icons. Click such an icon, or press Alt+Enter to auto-create a new method that you have not yet declared, fix an if/else statement, and much more:
The next level is static code analysis, or code inspections: your code is analyzed without actually executing it. Actually, RubyMine inspects code in the current file on-the-fly, and shows inspection results in the marker bar as colored stripes. If you see that the right side of your IDE frame is bright with red stripes, beware — it means that your code contains serious errors. Less important things, recommendations to improve code, or warnings, are displayed as yellow stripes. Information for the current file is summarized in a colored indicator on top of the marker bar, which works as traffic lights: green means that everything is fine; at least one problem turns the indicator yellow or red.
Sometimes you need to look deeper into your code. In this case, you have to inspect a whole project, or any of its parts () and explore the results in the Inspection Results Tool Window:
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 Inspections page of the Settings/Preferences dialog:
To help you make your source code less tangled and more readable, RubyMine offers searching for duplicates in the whole project or its part (). Take a look at the detected repetitive fragments in the Duplicates tool window and decide what to do with them.
RubyMine makes it possible to view existing documentation for the symbols at caret. There are several possible ways to do it:
Refer to the product documentation Viewing reference information.
After inspecting your code, you may be interested in code refactorings provided by RubyMine. The IDE helps you rename safely, extract methods, superclasses and modules, introduce variables, constants, parameters, and more. Use (Ctrl+Shift+Alt+T) 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:
To make this code DRY, extract a variable first. Place the caret on a code element and press Ctrl+Alt+V:
Next, extract a method (Ctrl+Alt+M).
After extracting the method, the local variable
method is no longer needed, so you can inline it (Ctrl+Alt+N):
If for some reason you want to rename your method, just place the caret on its name and press Shift+F6. RubyMine shows all the places that are to be changed and will perform all the changes for you:
Create and run tests
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.
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 and your source code nicer and cleaner.
Enjoy developing with RubyMine!