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 Create 'script'.
In the Create Run Configuration dialog, specify the following settings:
Name: Enter the run/debug configuration name, for example, rails runner.
Working directory: Specify the path to the root project directory. In our example, it will be /Users/jetbrains/RubymineProjects/sample_rails_app.
Enable the Execute in the context of Rails option to run the script in the Rails context.
Debug the script
To debug the newly created rails runner configuration, do the following: