A typical Rails development environment includes an editor, a terminal for running a web server, and a utility terminal for managing files, using version control, running tests, etc. During development, you’re constantly switching between your editor and these external terminals. RubyMine, an Integrated Development Environment, can eliminate this tedious back and forth workflow. In this post, we’ll learn how to run programs in RubyMine on OS X; allowing you to stay in RubyMine all day long.
To run a file, open the file in the editor or select the file in the project tool window, then press
control + shift + R. Rerun a file with
control + R.
These commands are commonly used to run test files, but they could also be used to run a simple Ruby script.
Run Tool Window
All running programs are displayed in the Run tool window. Press
command + 4 to open the Run tool window.
Stop a running program with
command + F2. Use
command + shift + [ and
command + shift + ] to navigate between multiple running programs.
In a test file, press
control + shift + R outside of any individual test to run all the tests in the file. Press
control + shift + R within an individual test to run just that test.
Open the run dialog with
control + alt/option + R. The run dialog lists recently run programs. This is useful for when you want to rerun a test you ran several tests ago.
By default, this dialog also includes commands to run a development server, and your entire test suite.
Ruby/Rails Quick List
command + option + R to open the Ruby/Rails quick list. The Ruby/Rails quick list includes several useful commands such as, starting a Rails console, and starting an IRB session.
You can run a file or a code selection in an existing IRB or Rails console with
alt/option + shift + L. View IRB history with
command + E.
Running Rake Tasks
Run a Rake task with
alt/option + R.
If a custom Rake task doesn’t appear in the list, reload Rake tasks from this dialog or the Ruby/Rails quick list (
command + alt/option + R).
Running Rails Generators
Run a Rails generator with
command + alt/option + G.
If a custom Rails generator task doesn’t appear in the list, reload Rails generators from this dialog or the Ruby/Rails quick list (
command + alt/option + R).
Take Advantage of Your IDE
IDEs increase your productivity by combining all of your development tools into one program. Frequent context switching to external tools not only slows you down, but also requires more in-depth knowledge of each tool. Try gradually replacing external tools with their IDE equivalents. Over time, your knowledge of shell command options and obscure Git commands will no longer seem very important to you.
About the Author
BiographyMore Content by Jared Carroll