Episodes

Resources

Download Source Code

Summary

# Terminal
rails db:system:change --to=postgresql
bin/rails credentials:edit
chmod +x bin/render-build.sh
bundle lock --add-platform x86_64-linux

# config/database.yml
production:
  <<: *default
  url: <%= ENV["DATABASE_URL"] %>
  # url: <%= Rails.application.credentials.database_url %>

# render.yaml
databases:
  - name: exampledb
    databaseName: exampledb
    user: exampleuser
    plan: free

services:
  - type: web
    name: example
    plan: free
    env: ruby
    buildCommand: "./bin/render-build.sh"
    startCommand: "bundle exec puma -C config/puma.rb"
    envVars:
      - key: DATABASE_URL
        fromDatabase:
          name: exampledb
          property: connectionString
      - key: RAILS_MASTER_KEY
        sync: false
      - key: RAILS_SERVE_STATIC_FILES
        value: true

# bin/render-build.sh
#!/usr/bin/env bash
set -o errexit
bundle install -j $(nproc)
bin/rails db:migrate
bin/rails assets:precompile