RubyMine 2022.2 Help

Tutorial: Debug a script in Rails context

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

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 the Ruby run/debug configuration for running this script using the Rails runner.

Create the run/debug configuration

  1. Right-click the lib/script.rb file in the editor and select Modify Run Configuration.

    Create the Ruby configuration
  2. In the Create Run Configuration dialog, specify the following settings:

    Configuration settings
    • Name: Enter the run/debug configuration name, for example, Rails runner.

    • Enable the Execute in the context of Rails option to run the script in the Rails context.

    Click OK.

Debug the script

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 created 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: 09 August 2022