Getting started with Ruby on Rails and Postgres on Supabase

- Create a Rails Project: Make sure your Ruby and Rails versions are up to date and create a new Rails project using
rails new
command with the --database
flag set to Postgres.
- Set up the Postgres connection details: Go to Supabase and create a new project, save your database password securely, and get the connection string from the database settings in the Supabase Dashboard.
- Create and run a database migration: Rails includes Active Record and migration tooling to generate SQL migration files. Use the
rails generate migration
command to create a migration file and run the migration with rails db:migrate
.
- Use the Model to interact with the database: Use the Rails console to interact with the database and perform CRUD operations.
- Set the connection string as a secret: Use the Fly.io CLI to set the Supabase database connection URI as a secret environment variable for the Rails app.
- Deploy the app: Use the
flyctl deploy
command to deploy the Rails app to Fly.io. Monitor the deployment process and ensure the app starts successfully.
- Options for connecting to your Postgres database: Supabase offers various options for connecting to your Postgres database, including URL connection string and SSL/TLS configurations.