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
Gemfilewith your dependencies
Don't have Ruby installed? Here's how to install it:
- Windows: Download from rubyinstaller.org with DevKit
- macOS: Use
brew install rubyor install via rbenv - Linux: Run
sudo apt install ruby-full(Ubuntu/Debian) or use rbenv
Once Ruby is installed, create a new Rails application:
gem install rails
rails new my-rails-app --database=postgresql
cd my-rails-appIf 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:
rails new myapp --api --database=postgresql
cd myappGenerate a simple controller in app/controllers/home_controller.rb:
class HomeController < ApplicationController
def index
render json: {
message: "Hello from Rails!",
status: "running"
}
end
def health
render json: { status: "healthy" }
end
endUpdate config/routes.rb:
Rails.application.routes.draw do
root "home#index"
get "health", to: "home#health"
endUpdate config/puma.rb for production:
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:
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:
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]
endCreate Procfile (no file extension):
web: bundle exec puma -C config/puma.rb
release: bundle exec rails db:migrateThis 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:
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
- Go to console.outplane.com
- Sign in with your GitHub account
- 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
Dockerfilein 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
mainor 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:
RAILS_ENV=production
SECRET_KEY_BASE=your-secure-random-string-here
RAILS_SERVE_STATIC_FILES=true
RAILS_LOG_TO_STDOUT=trueGenerate a secure SECRET_KEY_BASE with:
rails secretStep 3: Deploy
Click Deploy Application and watch the build process:
- Queued → Waiting for resources
- Building → Installing gems, precompiling assets
- Deploying → Starting your Rails application
- 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:
bundle exec puma -C config/puma.rbOut 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:
WEB_CONCURRENCY=2
RAILS_MAX_THREADS=5A common formula for workers is the number of CPU cores available.
Asset Pipeline
For Rails applications with frontend assets, ensure assets are precompiled:
- Buildpacks run
rails assets:precompileautomatically - Set
RAILS_SERVE_STATIC_FILES=trueto serve assets from Rails - For CDN delivery, configure
config.asset_hostin production
Secure Your Credentials
Rails 7+ uses encrypted credentials. For Out Plane, you can either:
Option A: Use environment variables (Recommended)
# 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
EDITOR="code --wait" rails credentials:edit --environment productionThen set RAILS_MASTER_KEY as an environment variable.
Connecting a Database
Most Rails applications need a database. Out Plane provides managed PostgreSQL:
- Go to Databases in the sidebar
- Click Create Database
- Select PostgreSQL version and region
- Copy the connection URL
Add the connection URL as an environment variable:
DATABASE_URL=postgres://user:password@host/databaseRails automatically uses DATABASE_URL when configured in database.yml:
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>Run Migrations
With the release command in your Procfile, migrations run automatically on each deployment:
release: bundle exec rails db:migrate
web: bundle exec puma -C config/puma.rbCustom Domain Setup
Replace the default .outplane.app URL with your own domain:
- Navigate to Domains
- Click Map Domain
- Enter your domain (e.g.,
app.yourdomain.com) - Add the DNS records shown to your domain registrar
Update your Rails configuration to allow the new host in config/environments/production.rb:
config.hosts << "app.yourdomain.com"
# Or allow all hosts
config.hosts.clearSSL 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:
config.hosts << ".outplane.app"Assets Not Loading
Verify asset configuration. Check that:
RAILS_SERVE_STATIC_FILES=trueis set- Assets precompile during build (check build logs)
- 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 "3.3.0"Database Connection Failed
Verify DATABASE_URL format. Ensure the connection string follows this format:
postgres://username:password@hostname:port/databaseMigration Errors
Check migration status. If migrations fail, check the build logs for specific errors. Common issues:
- Missing
DATABASE_URLenvironment 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:
- Connect your GitHub repository
- Configure port (8080), SECRET_KEY_BASE, and RAILS_ENV
- 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.