apps/docs/content/guides/getting-started/quickstarts/ruby-on-rails.mdx
<$Partial path="quickstart_create_project.mdx" />
Save your database password securely. You need it for the connection string.
With your Ruby and Rails versions up to date, run rails new on your terminal to scaffold a new project.
Use the -d=postgresql flag to set it up for Postgres.
Check the Rails docs for more details.
rails new blog -d=postgresql
cd blog
Supabase's Agent Skills is a curated set of instructions that give your AI agent procedural knowledge about working with Supabase.
Install them so your AI coding agent can produce more accurate, reliable code using current Supabase patterns, such as authentication, server-side rendering, and database migrations, rather than relying solely on training data.
To install, run the following command in the root of your project:
npx skills add supabase/agent-skills
The Supabase MCP server connects AI assistants to Supabase, allowing you to interact with your projects on your behalf. Find out more on how to add it to your client in the MCP docs.
Navigate to your project dashboard and click on Connect.
Look for the Session Pooler connection string and copy the string. You will need to replace the Password with your saved database password, and percent-encode any reserved characters it contains, such as &, #, ?, or a space. You can reset your database password in your Database Settings if you do not have it.
If you're in an IPv6 environment or have the IPv4 Add-On, you can use the direct connection string instead of Supavisor in Session mode.
</Admonition>Set the connection string as an environment variable. Rails reads DATABASE_URL from the environment and connects with it, so you don't need to edit config/database.yml. The export applies to the current shell session, so run it in the same shell as the Rails commands in the following steps. sslmode=require stops the driver from falling back to sending your data in plaintext.
export DATABASE_URL=postgres://postgres.[PROJECT-REF]:[YOUR-PASSWORD]@aws-[REGION].pooler.supabase.com:5432/postgres?sslmode=require
Rails includes Active Record as the ORM as well as database migration tooling which generates the SQL migration files for you.
Create an example Article model and generate the migration files.
bin/rails generate model Article title:string body:text
bin/rails db:migrate
You can use the included Rails console to interact with the database. For example, you can create new entries or list all entries in a Model's table.
bin/rails console
article = Article.new(title: "Hello Rails", body: "I am on Rails!")
article.save # Saves the entry to the database
Article.all
Run the development server. Go to http://127.0.0.1:3000 in a browser to see your application running.
bin/rails server