# Create and run your first Ruby projects

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

> **TL;DR**
> Completed project: [ruby_helloworld](https://github.com/rubyminedoc/ruby_helloworld)

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](set-up-a-ruby-development-environment.html#ruby) 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.

Procedure: Create an empty application

1. Run RubyMine and click New Project on the [Welcome Screen](null) .

![Welcome screen](https://resources.jetbrains.com/help/img/idea/2026.3/rm_welcome_screen_empty.png)

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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_dialog_ruby.png)

* 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](configuring-language-interpreter.html) installed in your system.

3. Click Create to continue.

Procedure: 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` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Ctrl+N` (TextMate), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)).

2. In the invoked popup, select Ruby File/Class and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![New Ruby Class](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_new_class_popup.png)

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

![New Ruby File/Class](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_new_file_dialog.png)

4. In the editor, insert the following code:

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

Procedure: Run the Ruby script

To run the created script, do the following:

1. Press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (TextMate), `Ctrl` (NetBeans), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) twice and type the following command:

```CONSOLE
ruby script.rb
```

Press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![Run ruby script](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_run_any_script.png)

2. In the Run tool window, type any name and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) to see a program's response.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_run_tool_window.mp4)

### 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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_configurations_dropdown.png)

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

![Run/Debug Configurations](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_ruby_configurations_dialog.png)

Find more information about run/debug configurations in [this topic](run-debug-configuration.html).

## Create a Rails application

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

Procedure:

1. Run RubyMine and click New Project on the [Welcome Screen](null).

![Welcome screen](https://resources.jetbrains.com/help/img/idea/2026.3/rm_welcome_screen_empty.png)

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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_dialog_rails.png)

* 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](configuring-language-interpreter.html) 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](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) 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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_install_rails_gem_dialog.png) 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](https://guides.rubyonrails.org/command_line.html#rails-new) 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. > **Tip:** > If you're using Rails 7 and later, you can select a CSS framework when creating your application. For this purpose, use the `--css` Rails option. For example, `--css=tailwind`.

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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_output.png)

6. After installing all dependencies, you can see the project structure in the Project tool window (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Meta+1` (TextMate), `Ctrl+1` (NetBeans), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))) on the left. On the right, RubyMine automatically opens the main project files in the editor.

![New Rails Application](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_ide.png)

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](version-control-integration.html) 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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_server_output.png)

3.

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

![Rails default page](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_browser.png)

## 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](#create-a-rails-application) and have it open in the editor.

Procedure: Add a controller

1. Press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (TextMate), `Ctrl` (NetBeans), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) twice and start typing controller. In the invoked list, select rails generate controller and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![rails g controller](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_run_any_controller.png)

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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_add_new_controller_dialog.png)

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](https://resources.jetbrains.com/help/img/idea/2026.3/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](https://guides.rubyonrails.org/getting_started.html#setting-the-application-home-page).

Procedure: Update a view

Add a button to the created view.

1. In the Project view (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Meta+1` (TextMate), `Ctrl+1` (NetBeans), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))), open the `app/views/welcome/index.html.erb` file.

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

```ERB

<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.

Procedure: 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` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Meta+Shift+N` (TextMate), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)) and select JavaScript File.

![New File](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_js_add_javascript.png)

3. Specify the file name (hello) and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![New JavaScript File](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_js_file_name.png)

4. In the created `hello.js` file, add the following code:

```JAVASCRIPT
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:

```JAVASCRIPT
import "hello"
```

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

```ERB
<%= javascript_importmap_tags %>
```

7. Open the `config/importmap.rb` file and add the following line:

```RUBY
pin "hello"
```

Procedure: Start a web server

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

1. Press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (TextMate), `Ctrl` (NetBeans), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) 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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_project_rails_server_output.png)

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](https://resources.jetbrains.com/help/img/idea/2026.3/rm_new_js_browser_click.png)

