Tutorial: Run a Sinatra application
Sinatra is a library for creating web applications. RubyMine allows you to run a Sinatra application directly as a Ruby script or by using the dedicated Rack run/debug configuration if you are using the rackup tool.
In this tutorial, we'll show you how to run the sample Sinatra application in RubyMine directly as a Ruby script, how to run the application by using the rackup tool, and how to configure additional running options using run/debug configurations.
Prerequisites
Before running the Sinatra application, make sure that the following prerequisites are met:
The 'sinatra' and 'rack' gems are installed to the project SDK.
The required web server gem (for example, 'thin' or 'puma') is installed to the project SDK.
Run an application as a Ruby script
Run an application
To run a Sinatra application as a Ruby script, follow the steps below:
Press Ctrl twice to invoke the Run Anything popup.
Type the following command in the popup and press Enter.
ruby app.rbIf necessary, you can specify the required command-line options and script arguments. For example, to run the application with the Puma server, use the following command:
ruby app.rb -s PumaIn this case, the
-s Puma
command part will be passed as Script arguments to the created Ruby configuration.Wait until RubyMine starts the application. The Run tool window shows the application's output.
Configure running options
After you run an application as a Ruby script, RubyMine automatically creates the Ruby run/debug configuration. You can customize it to pass additional options.
Select
from the main menu.In the opened Run/Debug Configurations dialog, select the created ruby app.rb configuration in the Ruby group, and pass the required running options in the Script arguments field. For example, to use the Puma server for this configuration, specify the following value:
-s PumaClick OK to save the configuration.
Run the application with 'config.ru'
To run the Sinatra application that uses config.ru file, follow the steps below:
Open the Project view Alt+1.
Right-click the config.ru and select Run 'config.ru'.
Wait until RubyMine starts the application. The Run tool window shows the application's output.
See Run Rack applications to learn more about running Rack applications.