RubyMine 2016.2 Help

Heroku. Getting Started

This tutorial illustrates main tasks related to working with Heroku.

Creating a Heroku user account

Go to the Heroku web site and sign up for a user account.

Generating and installing SSH keys

To be able to deploy your code to the cloud, you have to upload your public SSH key to Heroku. You can do that, for example, when registering your Heroku user account in RubyMine.

If you don't have a private/public SSH key pair, generate one. Search the Internet for corresponding tools and instructions.

Put your keys to the .ssh folder in your user home directory.

Making sure that Heroku and Git Integration plugins are enabled

To be able to work with Heroku and Git on Heroku, the Heroku Integration and the Git Integration plugins must be enabled. To make sure that these plugins are enabled, use the Plugins page of the Settings/Preferences dialog (Ctrl+Alt+S | Plugins).

Registering your Heroku user account in RubyMine

  1. Open the Settings/Preferences dialog (e.g. Ctrl+Alt+S) and select Build, Execution, Deployment | Heroku.
  2. Click add.
  3. Specify your user name and password.
    rm_HRRegisterUserAccount
  4. If you haven't uploaded your public SSH key to Heroku yet, you can do that now.

    Click Upload Public SSH Key and select the key file in the dialog that opens.

    The key file should have the .pub extension and may be called id_rsa.pub, id_dsa.pub or something similar.

  5. Click OK.

Creating a project

  1. Click Create New Project on the Welcome screen, or select File | New Project on the main menu.

    The New Project wizard opens.

  2. Specify the name for your new project (e.g. MyFirstAppForHeroku).
    rm_HRNewProjectName

    Click Create.

Exploring a run configuration

To deploy and debug your applications on Heroku, RubyMine provides Heroku Deployment run/debug configuration.

Let's take a quick look at its settings.

  1. Select Run | Edit Configurations.
    rm_HRRunConfig

    The run/debug configuration specifies that your source code should be deployed to Heroku.

    The application will be deployed under its default name, in this case, myfirstappforheroku. (The application name defines its URL, https://<app-name>.herokuapp.com/.) If you want to use a different name, select the Use custom application name check box and specify the name.

    If you wanted to use the run configuration also for debugging your app, you'd specify the debug host and port.

    To create another run configuration for Heroku, you should click add and select Heroku Deployment. For more information, see Working with Run/Debug Configurations and Run/Debug Configuration: Heroku Deployment.

  2. Click OK.

Deploying your app

  1. Start the run configuration: click run to the right of the run configuration selector or press Shift+F10.

    The Commit and Push dialog opens. This dialog is used to commit changes to your local Git repository and to push them to a remote Git repository, in this case, the one on Heroku.

  2. Write the commit message and click Push without Commit.

    As a result (all the following takes place on Heroku; you can monitor the process in the Application Servers tool window):

    • A Git repository for your app source code is created.
    • Your app is built and started.

    Finally, when your app is deployed, the link to it is shown within the line Application is available at ...

    HRK006AppDeployed
  3. Click the link.

    Your web browser opens and your application output is shown.

    HRK007OutputInBrowser

Modifying the source code

  1. Open the file hw.html for editing: select the file in the Project tool window and press F4.
  2. Change the text, say, to Hello from RubyMine!

Redeploying the app

To publish the changed version of your app, you should redeploy the app.

  1. In the Application Servers tool window, right-click your app and select Redeploy.
    HRK009Redeploy
  2. In the Commit and Push dialog, write the commit message and click Commit and Push.
    rm_HRK010CommitAndPush
  3. When the message '<app-name>' has been deployed successfully is output, switch to the web browser and reload the page to see the changes.
    rm_HRK011OutputInBrowser

Undeploying the app

When your app is no longer needed, you should undeploy it (i.e. remove it from Heroku along with its source code).

  1. In the Application Servers tool window, right-click your app and select Undeploy.
    HRK012Undeploy
  2. Provide your Heroku password to confirm your intention to delete the app.
  3. Switch to the web browser and reload the page to see that you app has become unavailable.
    HRK014NoSuchAppInBrowser

Disconnecting from Heroku

  • In the Application Servers tool window, right-click Heroku and select Disconnect.
    HRK015Disconnect

See Also

Last modified: 1 September 2016