RubyMine 2019.3 Help

Tutorial: Debug a Rails runner script

The Rails runner allows you to run Ruby code in the Rails context non-interactively. In this tutorial, we'll show you how to debug a Rails runner script in RubyMine.

For example, your project contains the Ruby script you want to debug at the following path: lib/script.rb. Before debugging, you need to create a run/debug configuration for running this script using the Rails runner.

Create the Rails runner configuration

  1. In the main menu, go to Run | Edit Configurations, click the Add icon, and select Gem Command from the list.

  2. In the Run/Debug Configurations dialog, specify the following settings:

    Run/Debug Configuration
    • Name: Enter the run/debug configuration name, for example, rails runner.

    • Gem name: Specify the rails gem here.

    • Executable name: Select the rails executable.

    • Arguments: Specify arguments for running the script using the Rails runner: r lib/script.rb.

    Click OK.

Debug the Rails runner configuration

To debug the newly created rails runner configuration, do the following:

  1. Set a breakpoint in the lib/script.rb file.

  2. Press Ctrl twice and type the configuration name in the popup: rails runner.

  3. Press and hold down the Shift key (the dialog title changes to Debug) and press Enter. RubyMine will suspend the script execution before the breakpoint.

    Rails runner debug

Last modified: 30 January 2020