Get Started with Ruby on Rails on Scalingo

Initialize your application

$ rails new my-app

# It creates files and run 'bundle install'

$ git init
$ git add .
$ git commit -m "Base rails application"

Create your application on Scalingo

$ scalingo create my-app
Git repository detected: remote scalingo added
→ 'git push scalingo master' to deploy your app

Provision and configure your database

  • Go on the dashboard of your application.
  • Select the Addons category
  • Choose the database you want to use


Add the gem pg to your Gemfile


Add the gem mysql to your Gemfile:

gem 'mysql2', '~> v0.3.18'

Then set the following environment variable:

  • DATABASE_URL → Copy the value of SCALINGO_MYSQL_URL and replace ‘mysql://’ by ‘mysql2://’


To use a MongoDB database your need to add the gem mongoid to your Gemfile. Please refer to this guide.

Setup your application logging

By default, Rails applications don’t write their logs to STDOUT but in a custom file. We expect your application to write all its logging entries to STDOUT and STDERR according to their nature, in accordance to the 12-factor.

  • Add the following gem in your Gemfile: gem "rails_12factor"

The rails_12factor gem includes two gems, one of them is rails_stdout_logging. Thanks to it, the application won’t write the logs to the log/production.log file but directly on the standard output.

Why writing the logs to the standard output

It is a requirement to let the platform aggregate them and let you browse your application logs in the dashboard or with Scalingo’s command line interface.

Serving static assets

The second gem included in rails_12factor is rails_serve_static_asset. It includes a middleware provided by sprocket to serve static files located in the /public directory of your project.

In a more traditional way to host a Ruby on Rails application, assets would not be served by the application server, but by a proxy web server (Apache/Nginx for instance), but you don’t need that on Scalingo.

Finalize and deploy

$ bundle install
$ git add .
$ git commit -m "Configure application for Scalingo"
$ git push scalingo master

Access your application

Waiting for your application to boot...
<-- -->

A new application will render a 404 error The page you were looking for doesn't exist., but it’s expected. There is nothing in the project, it’s time to build your product!

mode_edit Suggest edits