1. Create and deploy a Ruby on Rails hello app
You will see a hello response at / and ok at /health before adding any services.
1. Download and run locally
Download the hello ZIP into a working directory, then open a terminal in that directory:
unzip rails-hello.zip
cd rails-hello
bundle install
bundle exec puma -b tcp://0.0.0.0:3000
Keep it running. In another terminal, curl -fsS http://localhost:3000/health should print ok.
Open http://localhost:3000/ and confirm the hello message. Stop the server with Ctrl+C.
The app source is small enough to inspect in full:
Gemfile
source "https://rubygems.org"
ruby "~> 3.4.0"
gem "rails", "~> 8.0.0"
gem "puma", "~> 6.6"
Procfile
web: bundle exec puma -b tcp://0.0.0.0:$PORT
config.ru
require_relative "config/environment"
run Rails.application
Rakefile
require_relative "config/application"
Rails.application.load_tasks
bin/rails
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require "bundler/setup"
require "rails/commands"
config/application.rb
require "bundler/setup"
require "rails"
require "action_controller/railtie"
module HelloTutorial
class Application < Rails::Application
config.load_defaults 8.0
config.api_only = true
config.eager_load = ENV["RAILS_ENV"] == "production"
config.hosts << ENV["PAAS_PUBLIC_HOST"] if ENV["PAAS_PUBLIC_HOST"]
config.logger = ActiveSupport::Logger.new($stdout)
end
end
config/environment.rb
require_relative "application"
Rails.application.initialize!
config/routes.rb
Rails.application.routes.draw do
root "hello#index"
get "/health", to: "hello#health"
end
app/controllers/hello_controller.rb
class HelloController < ActionController::API
def index
render plain: "Hello from Rails on d2o!\n"
end
def health
render plain: "ok\n"
end
end
Keep the supplied lockfiles in Git. The buildpack uses these manifests and its runtime version declaration to reproduce the app’s dependencies.
2. Create the Environment
Dashboard: open Project Examples → create Environment rails, type Development,
branch main, release source Build, Automatic deployment on.
CLI:
paas envs create rails -o "$TUTORIAL_ORG" -p examples --type development --branch main --release-source build
3. Create the web app
Dashboard: inside rails choose Add Resource → Web Application.
Name it notes-web, choose Framework Ruby on Rails,
Repository The environment’s shared repository, Directory blank (repository root),
and Process type web. Use Port 3000, Health Check Path /health, and one replica.
Click Create Resource.
CLI:
paas apps create notes-web --framework rails --shared-source --start-command web --port 3000 --health-check-path /health -o "$TUTORIAL_ORG" -p examples -e rails
4. Set the Rails application secret
Generate a value locally with ruby -rsecurerandom -e 'puts SecureRandom.hex(64)'.
In the dashboard, open the rails Environment’s Secrets page and add
RAILS_SECRET_KEY_BASE with that value. Secret creation is currently dashboard-only,
including when you follow the CLI path. Do not put the value in Git or a plain config variable.
Dashboard: on notes-web → Config, add SECRET_KEY_BASE, choose Link to secret,
and select RAILS_SECRET_KEY_BASE.
CLI: after creating the secret in the dashboard:
paas config set --secret-ref RAILS_SECRET_KEY_BASE SECRET_KEY_BASE -a notes-web -o "$TUTORIAL_ORG" -p examples -e rails
The platform supplies the value at runtime. Local development can use a locally generated
SECRET_KEY_BASE; the source never contains a deployment secret.
5. Commit and push
Initialize a repository in the unpacked hello directory:
git init -b main
git add .
git commit -m "Add hello application"
Dashboard path: open the Environment’s Git remote panel, copy its shared-repository remote command into this directory, then run its push command. This is the Environment remote, not a per-app remote. The dashboard supplies the correct host and authentication URL.
CLI path: omit -a when setting the shared remote:
paas git remote -o "$TUTORIAL_ORG" -p examples -e rails
git push d2o main
paas watch -a notes-web -o "$TUTORIAL_ORG" -p examples -e rails
6. Verify the deployed app
Dashboard: open notes-web → Deployments, wait for the successful build and running
instance, then open its public URL. Append /health; it should display ok.
CLI: paas ps and paas logs with -o "$TUTORIAL_ORG" -p examples -e rails and -a notes-web show the running process.
Use the public URL displayed in the dashboard, or read the url field from
paas apps info notes-web --json with the same Organization, Project, and Environment flags.
APP_URL=https://your-app-host
curl -fsS "$APP_URL/health"
curl -fsS "$APP_URL/"
Set APP_URL to your actual URL, with no trailing slash. If the build fails, see
troubleshooting before continuing.
Next: Persist notes in PostgreSQL.