Deploy a Sample Ruby on Rails Application

Page last updated:

This topic guides the reader through deploying a sample Ruby on Rails app to Pivotal Web Services (PWS) .


In order to deploy a sample Ruby on Rails app, you must have the following:

Step 1: Clone the App

Run the following terminal command to create a local copy of the rails_sample_app.

$ git clone
The newly created directory contains a manifest.yml file, which assists CF with deploying the app. See Deploying with Application Manifests for more information.

Step 2: Log in and Target the API Endpoint

  1. Run the following terminal command to log in and target the API endpoint of your deployment. Use as your API endpoint.

    $ cf login -a YOUR-API-ENDPOINT
  2. Use your credentials to log in, and to select a Space and Org.

Note: The API endpoint must be entered in the format https://api.IP-ADDRESS, where IP-ADDRESS is the IP address of your API endpoint.

Step 3: Create a Service Instance

Run the following terminal command to create a PostgreSQL service instance for the sample app. Our service instance is rails-postgres. It uses the elephantsql service and the turtle plan.

$ cf create-service elephantsql turtle rails-postgres
Creating service rails-postgres in org YOUR-ORG / space development as

The manifest for the rails_sample_app contains a services sub-block in the applications block. The Cloud Foundry Command Line Interface tool (cf CLI) binds the service to the app.

- name: rails-sample
  memory: 256M
  instances: 1
  path: .
  command: bundle exec rake db:migrate && bundle exec rails s -p $PORT
    - rails-postgres

Step 4: Deploy the App

Make sure you are in the rails_sample_app directory. Run the following terminal command to deploy the app:

$ cf push rails_sample_app

cf push rails_sample_app creates a URL route to your application in the form HOST.DOMAIN. In this example, HOST is rails_sample_app. Administrators specify the DOMAIN. For example, for the DOMAIN, running cf push rails_sample_app creates the URL

The example below shows the terminal output when deploying the rails_sample_app. cf push uses the instructions in the manifest file to create the app, create and bind the route, and upload the app. It then binds the app to the rails-postgres service and follows the information in the manifest to start one instance of the app with 256M of RAM. After the app starts, the output displays the health and status of the app.

$ cf push rails_sample_app
Using manifest file ~/workspace/rails_sample_app/manifest.yml

Updating app rails_sample_app in org Cloud-Apps / space development as

Using route
Uploading rails_sample_app...
Uploading app files from: ~/workspace/rails_sample_app
Uploading 445.7K, 217 files
Binding service rails-postgres to app rails_sample_app in org Cloud-Apps / space development as

Starting app rails_sample_app in org Cloud-Apps / space development as


0 of 1 instances running, 1 starting
1 of 1 instances running

App started

Showing health and status for app rails_sample_app in org Cloud-Apps / space development as

requested state: started
instances: 1/1
usage: 256M x 1 instances

     state     since                    cpu    memory          disk
#0   running   2014-08-25 03:32:10 PM   0.0%   68.4M of 256M   73.4M of 1G

Note: If you want to view log activity while the app deploys, launch a new terminal window and run cf logs rails_sample_app.

Step 5: Verify the App

Verify that the app is running by browsing to the URL generated in the output of the previous step. In this example, navigating to verifies that the app is running.

You’ve now pushed an app to PWS! For more information about this topic, see the Deploy an Application topic.

Create a pull request or raise an issue on the source for this page in GitHub