Back to Blog
Tutorial

How to Deploy a Ruby on Rails Application in 1 Minute

Daniel Brooks6 min read
How to Deploy a Ruby on Rails Application in 1 Minute

Ruby on Rails remains one of the most productive web frameworks for building full-stack applications. Deploying Rails to production typically requires configuring Puma, managing assets, and setting up database connections.

With Out Plane, you can deploy your Rails application in under a minute. This guide shows you exactly how.

What You'll Need

Before starting, make sure you have:

  • Ruby 3.2+ installed on your machine
  • A GitHub account
  • A Rails application in a GitHub repository
  • A Gemfile with your dependencies

Don't have Ruby installed? Here's how to install it:

  • Windows: Download from rubyinstaller.org with DevKit
  • macOS: Use brew install ruby or install via rbenv
  • Linux: Run sudo apt install ruby-full (Ubuntu/Debian) or use rbenv

Once Ruby is installed, create a new Rails application:

bash
gem install rails
rails new my-rails-app --database=postgresql
cd my-rails-app

If you don't have a Rails app yet, use our example below.

Quick Start: Sample Rails Application

Create a new Rails API application with these commands:

bash
rails new myapp --api --database=postgresql
cd myapp

Generate a simple controller in app/controllers/home_controller.rb:

ruby
class HomeController < ApplicationController
  def index
    render json: {
      message: "Hello from Rails!",
      status: "running"
    }
  end

  def health
    render json: { status: "healthy" }
  end
end

Update config/routes.rb:

ruby
Rails.application.routes.draw do
  root "home#index"
  get "health", to: "home#health"
end

Update config/puma.rb for production:

ruby
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

port ENV.fetch("PORT") { 8080 }

environment ENV.fetch("RAILS_ENV") { "production" }

pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

workers ENV.fetch("WEB_CONCURRENCY") { 2 }

preload_app!

Update config/database.yml for production:

yaml
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: myapp_development

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  url: <%= ENV['DATABASE_URL'] %>

Ensure your Gemfile includes:

ruby
source "https://rubygems.org"

ruby "3.3.0"

gem "rails", "~> 7.2.0"
gem "pg", "~> 1.5"
gem "puma", ">= 5.0"
gem "bootsnap", require: false

group :development, :test do
  gem "debug", platforms: %i[mri mingw x64_mingw]
end

Create Procfile (no file extension):

text
web: bundle exec puma -C config/puma.rb
release: bundle exec rails db:migrate

This tells Buildpacks how to start your application and run migrations on each release.

Push this code to a GitHub repository, and you're ready to deploy.

Optional: Add a Dockerfile

If you prefer full control over the build process, create a Dockerfile:

dockerfile
FROM ruby:3.3-slim

RUN apt-get update -qq && apt-get install -y \
    build-essential \
    libpq-dev \
    nodejs \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY Gemfile Gemfile.lock ./
RUN bundle install --without development test

COPY . .

RUN bundle exec rails assets:precompile

EXPOSE 8080

CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

With a Dockerfile, select Dockerfile as your build method. Without one, select Buildpacks and Out Plane handles everything automatically.

Deploy in 3 Steps

Step 1: Connect Your Repository

  1. Go to console.outplane.com
  2. Sign in with your GitHub account
  3. Select your Rails repository from the list

Out Plane automatically detects Ruby applications and configures the build process using Buildpacks.

Step 2: Configure Your Application

Configure the following settings in the create application form:

Build Method

Select how Out Plane should build your application:

  • Buildpacks (Recommended): Automatically detects Ruby, installs gems, and precompiles assets. No additional configuration needed.
  • Dockerfile: Use this if you have a custom Dockerfile in your repository for full control over the build process.

For most Rails applications, Buildpacks is the easiest option.

Basic Settings

  • Port: Set to 8080
  • Branch: Select main or your preferred branch
  • Region: Choose the region closest to your users

Environment Variables (Required)

Rails requires certain environment variables for production. Add these using the Add button or Raw Edit:

text
RAILS_ENV=production
SECRET_KEY_BASE=your-secure-random-string-here
RAILS_SERVE_STATIC_FILES=true
RAILS_LOG_TO_STDOUT=true

Generate a secure SECRET_KEY_BASE with:

bash
rails secret

Step 3: Deploy

Click Deploy Application and watch the build process:

  1. Queued → Waiting for resources
  2. Building → Installing gems, precompiling assets
  3. Deploying → Starting your Rails application
  4. Ready → Your app is live

Once the status shows Ready, your application is live. You can find your application URL at the top of the deployment page. Click the URL to open your Rails app in a new tab. SSL is automatically configured.

Production Best Practices

Use Puma for Production

Puma is Rails' default application server and handles concurrent requests efficiently:

bash
bundle exec puma -C config/puma.rb

Out Plane's Buildpacks automatically detect Puma and configure it properly.

Configure Workers and Threads

For better performance under load, adjust Puma settings via environment variables:

text
WEB_CONCURRENCY=2
RAILS_MAX_THREADS=5

A common formula for workers is the number of CPU cores available.

Asset Pipeline

For Rails applications with frontend assets, ensure assets are precompiled:

  1. Buildpacks run rails assets:precompile automatically
  2. Set RAILS_SERVE_STATIC_FILES=true to serve assets from Rails
  3. For CDN delivery, configure config.asset_host in production

Secure Your Credentials

Rails 7+ uses encrypted credentials. For Out Plane, you can either:

Option A: Use environment variables (Recommended)

ruby
# config/database.yml
production:
  url: <%= ENV['DATABASE_URL'] %>

# Access in code
Rails.application.config.some_api_key = ENV['API_KEY']

Option B: Use Rails credentials

bash
EDITOR="code --wait" rails credentials:edit --environment production

Then set RAILS_MASTER_KEY as an environment variable.

Connecting a Database

Most Rails applications need a database. Out Plane provides managed PostgreSQL:

  1. Go to Databases in the sidebar
  2. Click Create Database
  3. Select PostgreSQL version and region
  4. Copy the connection URL

Add the connection URL as an environment variable:

text
DATABASE_URL=postgres://user:password@host/database

Rails automatically uses DATABASE_URL when configured in database.yml:

yaml
production:
  <<: *default
  url: <%= ENV['DATABASE_URL'] %>

Run Migrations

With the release command in your Procfile, migrations run automatically on each deployment:

text
release: bundle exec rails db:migrate
web: bundle exec puma -C config/puma.rb

Custom Domain Setup

Replace the default .outplane.app URL with your own domain:

  1. Navigate to Domains
  2. Click Map Domain
  3. Enter your domain (e.g., app.yourdomain.com)
  4. Add the DNS records shown to your domain registrar

Update your Rails configuration to allow the new host in config/environments/production.rb:

ruby
config.hosts << "app.yourdomain.com"
# Or allow all hosts
config.hosts.clear

SSL certificates are automatically provisioned once DNS propagates.

Monitoring Your Application

After deployment, monitor your Rails application:

  • Logs: View real-time application logs including Puma access logs
  • Metrics: Track CPU, memory, and network usage
  • HTTP Logs: Analyze incoming requests, response times, and status codes

Access these from the sidebar in your application dashboard.

Troubleshooting

Application Won't Start

Check the port configuration. Make sure you set the port to 8080 in the application settings and your puma.rb reads from the PORT environment variable.

Blocked Host Error

Update config.hosts. Add your Out Plane domain in config/environments/production.rb:

ruby
config.hosts << ".outplane.app"

Assets Not Loading

Verify asset configuration. Check that:

  1. RAILS_SERVE_STATIC_FILES=true is set
  2. Assets precompile during build (check build logs)
  3. Asset paths are correct in your views

Bundle Install Failed

Check Ruby version compatibility. Ensure your Gemfile specifies a Ruby version that matches your local development:

ruby
ruby "3.3.0"

Database Connection Failed

Verify DATABASE_URL format. Ensure the connection string follows this format:

text
postgres://username:password@hostname:port/database

Migration Errors

Check migration status. If migrations fail, check the build logs for specific errors. Common issues:

  • Missing DATABASE_URL environment variable
  • Incompatible migration syntax
  • Missing database extensions

Next Steps

Your Rails application is now deployed and running in production. Here's what to explore next:

  • Scale your application: Adjust instance types and auto-scaling settings for higher traffic
  • Set up CI/CD: Enable automatic deployments on every git push
  • Add background jobs: Configure Sidekiq or Solid Queue with Redis
  • Enable caching: Add Redis for fragment and session caching

Summary

Deploying a Ruby on Rails application to Out Plane takes three steps:

  1. Connect your GitHub repository
  2. Configure port (8080), SECRET_KEY_BASE, and RAILS_ENV
  3. Deploy and get your live URL

No server configuration, no manual SSL setup, no infrastructure management. Puma handles requests, and migrations run automatically on each deploy.

Ready to deploy your Rails application? Get started with Out Plane and receive $20 in free credit.


Tags

ruby
rails
deployment
tutorial
web-framework

Start deploying in minutes

Connect your GitHub repository and deploy your first application today. $20 free credit. No credit card required.