RubyMine 2021.2 Help

Run Rails applications

RubyMine allows you to run or debug Rails applications by using the configured set of startup parameters - run/debug configurations. For instance, you can specify the following parameters for the Rails run/debug configuration: a server type (such as Puma or Passenger), IP address and port, environment (development by default), and so on. Note that for Rails projects, RubyMine automatically creates the development and production run/debug configurations with the corresponding Rails environments.

In this topic we'll show you how to:

Run the Rails server without configuring

To run the Rails server for the first time without any configuring, do the following:

  1. Press Ctrl twice.

  2. Type the rails server command in the invoked popup and press Enter.

  3. Wait until RubyMine starts the Rails server. The Run tool window shows the application's output.

    Run tool window / run Rails application

After you've run the Rails server, RubyMine automatically creates a special profile - a temporary run/debug configuration. You can customize settings of this configuration, for example, a server type, IP address and port, environment, and so on. Then, you can save the customized configuration to quickly run this configuration in the future.

Run the Rails server using a run/debug configuration

You can run the Rails server with the existing run/debug configurations in one of the following ways:

  • Press Ctrl twice to invoke the Run Anything popup. Start typing the required configuration name, select it from the list, and press Enter.

    Run Anything / run configuration
  • Select the desired configuration on the toolbar and click Run Shift+F10.

    Run selected configuration
  • Select Run | Run... Alt+Shift+F10 from the main menu, select the desired configuration from the list and press Enter.

    Select run configuration

Configure Rails server parameters

When you run the Rails server for the first time, RubyMine automatically creates a corresponding Rails temporary configuration, which can be saved. If necessary, you can create the Rails run/debug configuration manually from the predefined template.

To customize the run/debug configuration, do the following:

  1. Open the Run/Debug Configuration dialog in one of the following ways:

    • Select Run | Edit Configurations from the main menu.

    • With the Navigation bar visible (View | Appearance | Navigation Bar), choose Edit Configurations from the run/debug configuration selector.

      Edit run configurations

    • Press Alt+Shift+F10 and then press 0.

  2. In the opened Run/Debug Configurations dialog, select the required configuration in the Rails group, and specify its settings.

    Run/Debug Configurations: Rails

Run/debug configuration: Rails

Configuration tab

ItemDescription
Server

Specify a web server for running a Rails application. You might need to install a corresponding gem to the project SDK (for example,

Available servers:

Trinidad and Torquebox notes

Both Trinidad and TorqueBox servers require the following prerequisites to be met:

  • Use JRuby 1.7.x as the project interpreter.

  • To debug Rails applications on these servers:

    • Add the following dependencies to your Gemfile:

      gem 'ruby-debug-base', '>= 0.10.5.rc10' gem 'ruby-debug-ide', '>= 0.4.23.beta10'
    • Set the value of the Debug connection timeout option to 20-25 seconds (Settings/Preferences | Build, Execution, Deployment | Debugger | Ruby).

  • To run Rails applications on these servers, add the following dependencies to your Gemfile:

    gem 'torquebox' gem 'trinidad'

Unicorn notes

Note that Unicorn kills worker processes that take too long to respond. To avoid error messages, add the following lines to the unicorn configuration file unicorn.rb:

if ENV['IDE_PROCESS_DISPATCHER'] timeout 30 * 60 * 60 * 24 end
IP AddressSpecify the IP address where the Rails server will be accessible.
PortSpecify the port to run the Rails server.
Server argumentsType optional server arguments. You can run the rails server --help command in the terminal emulator to learn more about available arguments.
EnvironmentSelect the required Rails environment to run the server (development, production, or test).
Dummy appThis field is only enabled for the Rails mountable engine projects. Specify the absolute path to the dummy directory. This path is required to run the engine.
Environment variables

Specify the list of environment variables as the name-value pairs, separated with semi-colons. Alternatively, click the Browse button to create variables and specify their values in the Environment Variables dialog.

Ruby arguments

Specify the command-line arguments to be passed to the Ruby interpreter.

When such a run/debug configuration is launched, RubyMine analyzes the running processes, and does one of the following, depending on the presence of the running Nailgun server:

  • If there is no running Nailgun server, or if there is a Nailgun server on a non-default port, or with a different gemset, then RubyMine suggests to specify the desired port number.

  • If a Nailgun server runs on the default port with the required gemset, RubyMine does nothing.

  • If a Nailgun server runs on a different port with the required gemset, then RubyMine suggests to specify the desired port number.

  • If a Nailgun server runs on the default port with a different gemset, then RubyMine deletes the --ng argument.

Classpath property is added to Nailgun settings.

Ruby SDKSpecify the desired Ruby interpreter. You can choose the project default Ruby SDK, or select a different one from the list of configured Ruby SDKs.
Run browserSelect this option to enable opening an application automatically in a default browser.
Start JavaScript debugger automatically

Enable this option to start the JavaScript debugger.

Ruby arguments

Specify the command-line arguments to be passed to the Ruby interpreter.

Ruby SDKSpecify the desired Ruby interpreter. You can choose the project default Ruby SDK, or select a different one from the list of configured Ruby SDKs.

Rerun an application

To rerun the launched application, do the following:

  1. In the Run tool window, select the tab where the desired application is opened.

  2. In the toolbar of the Run tool window, click the Rerun button Ctrl+F5.

Last modified: 13 October 2021