RubyMine 2026.2 Help

Create and run your first Ruby projects

This topic explains how to do the following in RubyMine:

  • Create your first empty application

  • Create and run a Ruby file

  • Create and run your first Rails application

  • Add a JavaScript asset to a Rails application

  • Run your Rails application with the added JavaScript asset

Before performing the procedures below, download and install the Ruby distribution and set up your IDE.

We'll perform all procedures using RubyMine installed on macOS.

Create your first application

In this chapter, you will learn how to create an empty application, add a Ruby file, and run it.

Create an empty application

  1. Run RubyMine and click New Project on the Welcome Screen.

    Welcome screen
  2. In the New Project dialog, make sure that Empty Project is selected on the left pane. Then, specify the following settings:

    New Project dialog / Empty
    • Name: specify a name for the project (in our case, ruby_helloworld)

    • Location: specify a path to the directory in which you want to create the project. By default, RubyMine creates a directory with the same name as the project.

    • Interpreter: select a required Ruby interpreter installed in your system.

  3. Click Create to continue.

Create a Ruby file

After creating a project, you will see its structure in the Project tool window on the left. To add a Ruby file, do the following:

  1. Select a project root in the Project tool window and press Alt+Insert.

  2. In the invoked popup, select Ruby File/Class and press Enter.

    New Ruby Class
  3. In the invoked popup, specify a script name (script in our case) and click OK.

    New Ruby File/Class
  4. In the editor, insert the following code:

    puts "Please enter your name" name = gets.chomp puts "Hello, #{name}! I'm Ruby!"

Run the Ruby script

To run the created script, do the following:

  1. Press Ctrl twice and type the following command:

    ruby script.rb

    Press Enter.

    Run ruby script
  2. In the Run tool window, type any name and press Enter to see a program's response.

Run/debug configurations

After you run a Ruby script, RubyMine automatically creates a special profile, a run/debug configuration. Such profiles are used for running, debugging and testing applications, and specifies the script name, working directory, actions to be performed before launch, and so on.

To edit a configuration, call the dropdown menu under the Run widget and select Edit Configurations.

Edit Configurations

In the invoked Run/Debug Configurations dialog, you can specify the settings required to launch your script.

Run/Debug Configurations

Find more information about run/debug configurations in this topic.

Create a Rails application

In this chapter, you will learn how to create a Rails application and run it.

  1. Run RubyMine and click New Project on the Welcome Screen.

    Welcome screen
  2. In the New Project dialog, select Application in the Rails group Ruby on Rails in the Project Type group on the left pane.

  3. Specify the following settings:

    New Project dialog: Rails application
    • Name: specify a name for the project (rails-helloworld in our case).

    • Location: specify a path to the directory in which you want to create the project. By default, RubyMine creates a directory with the same name as the project.

    • Interpreter: select a Ruby interpreter that you want to use in your project.

    • Rails version: select a Rails version that you want to use in your project. If the Rails gem is not installed in the selected interpreter or the necessary Rails version is missing, click the Install Rails Gem button in the field. Wait until RubyMine downloads all available Rails versions and select the necessary version from the dropdown. Click OK to continue.

      Install rails gem

      If the selected version is not installed yet, RubyMine will install it upon project creation.

    • Extra options: provide additional Rails options for project creation in the Extra options field.

      For example, you can specify arguments that you will normally use to append the rails new command: --skip-tests to skip creation of test files, --skip-action-mailer to skip Action Mailer files, --skip-action-cable to skip Action Cable files, and so on.

      To get a full list of Rails options compatible with the Rails version in use, run the rails new --help command.

  4. Click Create to close the New Project dialog.

  5. RubyMine creates a new Rails application, installs the gem dependencies mentioned in Gemfile, and installs JavaScript dependencies mentioned in the project's package.json file. You can see this process in the Run tool window.

    Generating Rails Application for a project
  6. After installing all dependencies, you can see the project structure in the Project tool window (Alt+1) on the left. On the right, RubyMine automatically opens the main project files in the editor.

    New Rails Application

    If you have Git installed in your operating system, generating a new Rails application also initializes a Git repository. You can learn how to work with Version control systems in RubyMine from the Version control section.

  7. Now we have a functioning Rails application. To see it in action, you need to start a web server. Perform the following steps to do this:

    1. Click the Run icon in the upper right corner.

    2. RubyMine will show the process of preparing the application to run.

      Rails server output
    3. Open http://127.0.0.1:3000 in your browser to see the Rails default information page.

      Rails default page

Add a JavaScript asset to a Rails application

This chapter explains how to add a JavaScript asset to a Rails project and run the applciation to see how it works . We will use the empty Rails application created in the previous procedure. The steps below assume that you have already created this project and have it open in the editor.

Add a controller

  1. Press Ctrl twice and start typing controller. In the invoked list, select rails generate controller and press Enter.

    rails g controller
  2. In the invoked Add New Controller dialog, set the controller name to Welcome and add one action called index. Click OK.

    Add New Controller
  3. RubyMine will create a controller, view, and several other files. This process will be displayed in the Run tool window. In this window, click the index.html.erb file.

    generate script output
  4. To set the home page of your application to index, open the config/routes.rb file and add the following line within the Rails.application.routes.draw do ... end block:

    root 'welcome#index'

    Learn more at Setting the Application Home Page.

Update a view

Add a button to the created view.

  1. In the Project view (Alt+1), open the app/views/welcome/index.html.erb file.

  2. Replace the current content of the file with the following code:

    <h1>Hello, Rails!</h1> <button id="greet-user-button">Hello!</button>

    Apart from the existing static text within the h1 tag, the view file now contains a button element with a specific identifier that will be used in JavaScript.

Add a JavaScript handler

Now, create a JavaScript file that will handle the button click.

  1. In the Project view, select the app/javascript directory.

  2. Press Alt+Insert and select JavaScript File.

    New File
  3. Specify the file name (hello) and press Enter.

    New JavaScript File
  4. In the created hello.js file, add the following code:

    const button = document.getElementById("greet-user-button") if (button) { button.addEventListener("click", () => { alert("Hello!, JavaScript!") }) }

    In this script we:

    • Find the button by its identifier.

    • Attach a click handler that displays an alert and logs a message to the console.

  5. To make this file available in the application, open app/javascript/application.js and add:

    import "hello"
  6. Ensure that the application layout includes JavaScript assets. Open app/views/layouts/application.html.erb and verify that it contains:

    <%= javascript_importmap_tags %>
  7. Open the config/importmap.rb file and add the following line:

    pin "hello"

Start a web server

To see our application in action, you need to start a web server.

  1. Press Ctrl twice and start typing development.

  2. Click the Run icon in the upper right corner.

  3. RubyMine will show the process of preparing the application to run.

    Rails server output
  4. Open http://127.0.0.1:3000 in your browser. Then click the Hello! button to see the alert.

    Rm new js browser click
01 September 2026