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
Right-click the lib/script.rb file in the editor and select Modify Run Configuration.
In the Create Run Configuration dialog, specify the following 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:
Set a breakpoint in the lib/script.rb file.
Press Ctrl twice and type the created configuration name in the popup:
Rails runner
.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.