---
title: "Getting started with Ruby on Rails and Postgres on Supabase"
description: "A Rails app can be wired to a Supabase-hosted Postgres database by scaffolding with `rails new -d=postgresql` and supplying the Supabase pooler connection URI through the `DATABASE_URL` environment variable."
url: "https://swe.quest/articles/getting-started-with-ruby-on-rails-and-postgres-on-supabase-03d6ca4747754aea"
canonical: "https://supabase.com/blog/ruby-on-rails-postgres"
source: "Supabase"
published: "2024-01-29"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["ruby","postgres","deployment"]
---

# Getting started with Ruby on Rails and Postgres on Supabase

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-01-29, 3 min read, How-to. Original: [https://supabase.com/blog/ruby-on-rails-postgres](https://supabase.com/blog/ruby-on-rails-postgres)

## Summary

A Rails app can be wired to a Supabase-hosted Postgres database by scaffolding with \`rails new -d=postgresql\` and supplying the Supabase pooler connection URI through the \`DATABASE\_URL\` environment variable. The walkthrough generates an Article scaffold, runs migrations, inserts and queries records from the Rails console, and routes the root path to the articles index. Deployment to Fly.io uses \`fly launch\` with Postgres provisioning set to none, the connection string stored as a Fly secret, and \`fly deploy\`.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- Ruby on Rails basics ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))
- command-line usage

## Keywords

Ruby on Rails, Supabase, PostgreSQL, Active Record, Fly.io, flyctl

## Related posts

- [Getting started with Laravel and Postgres](https://swe.quest/articles/getting-started-with-laravel-and-postgres-e9ee98d4a4f87aab.md): Supabase · 2024-01-22 · Medium · 2 min read · PHP, PostgreSQL
  A new Laravel app can be connected to a Supabase-hosted Postgres database in a few steps: scaffold the project with Composer, install Laravel Breeze for built-in authentication, set DB\_CONNECTION=pgsql and DATABASE\_URL to the Supabase pooler connection string, then run migrations and start the dev server.
- [Fly Postgres, managed by Supabase](https://swe.quest/articles/fly-postgres-managed-by-supabase-c2ddce21256b3097.md): Supabase · 2023-12-15 · Easy · 4 min read · PostgreSQL, Cloud platforms, Replication, Virtualization
  Supabase and Fly.io launched Fly Postgres, a managed Postgres running on Fly Machines (Firecracker VMs) with Supabase features like Supavisor pooling, pgvector, PITR, branching and auto-generated REST/GraphQL APIs; the offering has since been deprecated.
- [Supabase Branching](https://swe.quest/articles/supabase-branching-4fbb0c9896d51627.md): Supabase · 2023-12-13 · Medium · 5 min read · Schema migrations, PostgreSQL, CI/CD, Deployment
  Supabase Branching gives each Git branch an isolated hosted Preview environment with its own Postgres database, Auth, Storage, Realtime, Edge Functions and APIs, plus separate credentials.
- [Deploy a Dart App on Railway, Part 1](https://swe.quest/articles/deploy-a-dart-app-on-railway-part-1-9c43a3141edcb7ac.md): Railway · 2024-12-13 · Medium · 7 min read · Deployment, Containers, Cloud platforms, PostgreSQL
  A Flutter + Serverpod trivia app is deployed to Railway with a Railway-hosted PostgreSQL database, using the Railway CLI and a custom multi-stage Dockerfile that compiles the Dart server and bundles a Flutter web build into Serverpod's static webserver.
- [NoSQL Postgres: Add MongoDB compatibility to your Supabase projects with FerretDB](https://swe.quest/articles/nosql-postgres-add-mongodb-compatibility-to-your-supabase-projects-with-ferretdb-44595afd7e1b96f1.md): Supabase · 2024-01-31 · Medium · 4 min read · PostgreSQL, Databases, Containers
  FerretDB, an open source MongoDB-compatible proxy, can run on top of a Supabase Postgres database, storing each collection as a table in a \`ferretdb\` schema with documents as JSONB rows.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
