IntelliJ IDEA 2020.1 Help

Open and run Rails project in IntelliJ IDEA

In this tutorial, we’ll show you how to clone an existing Rails application, configure the Ruby interpreter, install dependencies, and run this application. The following application will be used for this purpose: Sample Rails App.

Prerequisites

Before working with the sample Rails project mentioned above, do the following:

Check out a project

First, we need to clone the repository containing the sample application:

  1. On the Welcome Screen, click Get from Version Control and select Git.

    Welcome Screen
  2. In the invoked Clone Repository dialog, insert the following repository address to the URL field: https://github.com/JetBrains/sample_rails_app.git.

    Get from Version Control

    Then, click the Clone button.

  3. After cloning the repository, you will be prompted to create an IntelliJ IDEA project from these sources.

    Checkout from Version Control

    Click Yes.

  4. In the invoked Import Project wizard, click Next on each page of the wizard leaving the default settings.

    Import Project wizard
  5. On the last page, click Finish.

    Import Project wizard

Configure Ruby SDK

Now we need to configure the Ruby interpreter for the project:

  1. Go to File | Project Structure, or press Ctrl+Shift+Alt+S.

  2. In the invoked Project Structure dialog, switch to the Modules page and select the Ruby interpreter.

    Project Structure dialog / Module page

    Click OK.

Install gem dependencies

To install gems specified in the project’s Gemfile, do the following:

  1. Press Ctrl twice and enter the following command: gem install bundler.

    Run Anything / gem install bundler

    Press Enter and wait until the Bundler gem is installed.

  2. Press Ctrl twice again and start typing bundle install. Then, select the bundle install command from the list and press Enter.

    Run Anything / bundle install
  3. In the invoked Bundle Install dialog, click Install.

    Bundle Install dialog
  4. Wait until IntelliJ IDEA installs all gems.

    Run Tool window / installing gems

Install JavaScript dependencies

To install JavaScript dependencies mentioned in the project's package.json file using Yarn, do the following:

  1. Press Ctrl twice again and start typing yarn install. Then, select the yarn install command from the list and press Enter.

    yarn install
  2. Wait until IntelliJ IDEA installs all gems.

    Run Tool window / installing packages

Run migrations

To run our Rails application, first we need to migrate the database:

  1. Press Ctrl twice and type db:migrate. Select rake db:migrate in the dropdown and press Enter.

    Run Anything / rake db:migrate
  2. Leave the default settings in the invoked Execute ‘db:migrate’ dialog and click OK.

    Execute db:migrate
  3. Wait until the migration is finished.

    Run tool window / running migrations

Run the application

To run our Rails application, we need to create a corresponding Rails configuration:

  1. Press Ctrl+Shift+A and start typing edit configurations. Select Edit Configurations and press Enter.

    Find Action
  2. In the invoked Run/Debug Configurations dialog, click Add New Configuration and select Rails.

    Run/Debug Configurations dialog
  3. Change the created configuration name to development and enable the Run browser option.

    Run/Debug Configurations dialog

    Click OK.

  4. Press Ctrl twice and start typing the name of the created configuration (development). Select it from the list and press Enter.

    Run Anything / run configuration
  5. In the Run tool window, IntelliJ IDEA will show the process of preparing the application to run ...

    Run tool window / run Rails application

    ... and then open the application in a browser.

    Rails application in a browser
Last modified: 15 April 2020