mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Closes DOCS-1616 ## Problem The remaining quickstarts don't follow the [quickstart template](https://github.com/supabase/supabase/blob/docs/quickstart-template/apps/docs/style-guide/templates/quickstart.md) either. ## Solution - **Heading IDs:** each numbered step ends with the template's ID, such as `[#create-the-client]`. - **Heading wording:** eight headings now use the template's wording, such as `Create the Supabase client`. - **Style:** the prose follows the word list and elements rules. **Not changed:** RedwoodJS, Spring Boot, and Refine. DOCS-1624 covers them. **Before and after:** numbered headings that use the template's wording. | Page | Before | After | | --- | --- | --- | | iOS | 5/8 | 6/8 | | Kotlin | 4/8 | 5/8 | | Flask, Flutter, Unity | 5/7 | 6/7 | | Expo | 6/7 | 7/7 | | Reflex | 7/7 | 7/7 | | Laravel | 3/7 | 3/7 | | Rails | 3/6 | 3/6 | **Possible errors, not changed:** - The iOS page opens **Xcode > New Project > iOS > App**. Xcode's menu might be **File > New > Project**. - The Vue page says to drop a type import that `supabaseClient.ts` doesn't have. ## Preview links | Page | Preview | | --- | --- | | Flask | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/flask) | | Reflex | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/reflex) | | Expo React Native | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/expo-react-native) | | Flutter | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/flutter) | | iOS SwiftUI | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/ios-swiftui) | | Kotlin | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/kotlin) | | Unity | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/unity) | | Laravel | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/laravel) | | Ruby on Rails | [Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/ruby-on-rails) | ## Review category (docs PRs only) <!-- If this PR changes docs and you're on the Supabase team, select one category. PRs from forks are always reviewed as Low, so you can skip this section. --> - [ ] Critical: needs a review as soon as possible - [ ] Urgent: the feature ships soon, or it's blocking something else - [ ] Moderate: good to have soon, not urgent - [ ] Low: get to it when you can ## Review instructions 1. Open the [Kotlin preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/kotlin) and click **Create the Supabase client** in the table of contents. The URL ends in `#create-the-client`. 2. Open the [Laravel preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/laravel) and click the **Run the database migrations** link in step 4. The page scrolls to step 7. ## Checklist Check all before review: - [ ] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
89 lines
2.8 KiB
Plaintext
89 lines
2.8 KiB
Plaintext
---
|
|
title: 'Use Supabase with Ruby on Rails'
|
|
subtitle: 'Learn how to create a Rails project and connect it to your Supabase Postgres database.'
|
|
breadcrumb: 'Framework Quickstarts'
|
|
---
|
|
|
|
<AiPrompt id="ruby-on-rails" />
|
|
|
|
<$Partial path="quickstart_create_project.mdx" />
|
|
|
|
Save your database password securely. You need it for the connection string.
|
|
|
|
<Admonition type="note">
|
|
|
|
This guide uses Rails' own Active Record models and migrations, not the shared `instruments` sample table used by other quickstarts.
|
|
|
|
</Admonition>
|
|
|
|
## 2. Create a Rails project [#create-an-app]
|
|
|
|
With your Ruby and Rails versions up to date, run `rails new` in your terminal to scaffold a project.
|
|
|
|
Use the `-d=postgresql` flag to set it up for Postgres.
|
|
|
|
For more information, see [Getting Started with Rails](https://guides.rubyonrails.org/getting_started.html) in the Rails guides.
|
|
|
|
```bash
|
|
rails new blog -d=postgresql
|
|
cd blog
|
|
```
|
|
|
|
## 3. Set up AI tooling (optional) [#set-up-ai-tooling]
|
|
|
|
<$Partial path="quickstart_ai_tooling.mdx" />
|
|
|
|
## 4. Set up the Postgres connection details [#set-up-the-postgres-connection-details]
|
|
|
|
<$Partial path="quickstart_connection_string.mdx" />
|
|
|
|
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.
|
|
|
|
```bash
|
|
export DATABASE_URL=postgres://postgres.[PROJECT-REF]:[YOUR-DATABASE-PASSWORD]@[POOLER-HOST]:5432/postgres?sslmode=require
|
|
```
|
|
|
|
## 5. Create and run a database migration [#create-and-run-a-database-migration]
|
|
|
|
Rails includes Active Record as the ORM, and migration tooling that generates the SQL migration files for you.
|
|
|
|
Create an example `Article` model and generate the migration files.
|
|
|
|
```bash
|
|
bin/rails generate model Article title:string body:text
|
|
bin/rails db:migrate
|
|
```
|
|
|
|
## 6. Use the model to interact with the database [#use-the-model-to-interact-with-the-database]
|
|
|
|
You can use the included Rails console to query and update the database. For example, you can create new entries or list all entries in a model's table.
|
|
|
|
```bash
|
|
bin/rails console
|
|
```
|
|
|
|
```rb name=irb
|
|
article = Article.new(title: "Hello Rails", body: "I am on Rails!")
|
|
article.save # Saves the entry to the database
|
|
|
|
Article.all
|
|
```
|
|
|
|
## 7. Start the app [#start-the-app]
|
|
|
|
Run the development server. Go to `http://127.0.0.1:3000` in a browser to see your app running.
|
|
|
|
```bash
|
|
bin/rails server
|
|
```
|
|
|
|
<$Partial path="quickstart_going_to_production.mdx" />
|
|
|
|
## Next steps
|
|
|
|
Build on this app with the following resources:
|
|
|
|
- Set up [Auth](/docs/guides/auth) for your app
|
|
- [Insert more data](/docs/guides/database/import-data) into your database
|
|
- Upload and serve static files using [Storage](/docs/guides/storage)
|