From 45632cb50349291fdc04682fd4e4d40102173ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thor=20=E9=9B=B7=E7=A5=9E=20Schaeff?= <5748289+thorwebdev@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:57:16 +0800 Subject: [PATCH] feat(blog): Rails getting started. (#20351) * feat(blog): Rails getting started. * chore: updates. * Update apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx Co-authored-by: Copple <10214025+kiwicopple@users.noreply.github.com> * Update apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx Co-authored-by: Copple <10214025+kiwicopple@users.noreply.github.com> * Update apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx Co-authored-by: Copple <10214025+kiwicopple@users.noreply.github.com> * chore: fly deploy and session mode. * Apply suggestions from code review Co-authored-by: Ant Wilson * chore: session mode. * chore: better secrets. * Apply suggestions from code review Co-authored-by: Copple <10214025+kiwicopple@users.noreply.github.com> --------- Co-authored-by: Ant Wilson Co-authored-by: Copple <10214025+kiwicopple@users.noreply.github.com> --- .../getting-started/quickstarts/laravel.mdx | 4 +- .../quickstarts/ruby-on-rails.mdx | 4 +- .../www/_blog/2024-01-22-laravel-postgres.mdx | 2 +- .../2024-01-29-ruby-on-rails-postgres.mdx | 155 ++++++++++++++++++ .../blog/getting-started/rails/rails.jpg | Bin 0 -> 137367 bytes 5 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx create mode 100644 apps/www/public/images/blog/getting-started/rails/rails.jpg diff --git a/apps/docs/pages/guides/getting-started/quickstarts/laravel.mdx b/apps/docs/pages/guides/getting-started/quickstarts/laravel.mdx index 84ad9a05cab..9d51cde217a 100644 --- a/apps/docs/pages/guides/getting-started/quickstarts/laravel.mdx +++ b/apps/docs/pages/guides/getting-started/quickstarts/laravel.mdx @@ -54,6 +54,8 @@ export const meta = { When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string. + In this quickstart, we are going to connect via the connection pooler. Make sure to select `Session mode`! If your network supports IPv6, you can connect to the database directly without using the connection pooler. + Laravel ships with a Postgres adapter out of the box, you can simply configure it via the environment variables. You can find the database URL in your [Supabase Dashboard](/dashboard/project/_/settings/database). @@ -62,7 +64,7 @@ export const meta = { ```bash .env DB_CONNECTION=pgsql - DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres + DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres ``` diff --git a/apps/docs/pages/guides/getting-started/quickstarts/ruby-on-rails.mdx b/apps/docs/pages/guides/getting-started/quickstarts/ruby-on-rails.mdx index 0ae0e7fb31e..55d27d01913 100644 --- a/apps/docs/pages/guides/getting-started/quickstarts/ruby-on-rails.mdx +++ b/apps/docs/pages/guides/getting-started/quickstarts/ruby-on-rails.mdx @@ -36,6 +36,8 @@ export const meta = { When your project is up and running, navigate to the [database settings](https://supabase.com/dashboard/project/_/settings/database) to find the URI connection string. + In this quickstart, we are going to connect via the connection pooler. Make sure to select `Session mode`! If your network supports IPv6, you can connect to the database directly without using the connection pooler. + Rails ships with a Postgres adapter included, you can simply configure it via the environment variables. You can find the database URL in your [Supabase Dashboard](/dashboard/project/_/settings/database). @@ -43,7 +45,7 @@ export const meta = { ```bash Terminal - export DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres + export DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres ``` diff --git a/apps/www/_blog/2024-01-22-laravel-postgres.mdx b/apps/www/_blog/2024-01-22-laravel-postgres.mdx index 1a1a78fe677..a677113a1fa 100644 --- a/apps/www/_blog/2024-01-22-laravel-postgres.mdx +++ b/apps/www/_blog/2024-01-22-laravel-postgres.mdx @@ -71,7 +71,7 @@ Laravel ships with a Postgres adapter out of the box, you can simply configure i ```bash .env DB_CONNECTION=pgsql -DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres +DATABASE_URL=postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:5432/postgres ``` ### Change the default schema diff --git a/apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx b/apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx new file mode 100644 index 00000000000..25214352417 --- /dev/null +++ b/apps/www/_blog/2024-01-29-ruby-on-rails-postgres.mdx @@ -0,0 +1,155 @@ +--- +title: Getting started with Ruby on Rails and Postgres on Supabase +description: 'Learn how to create a new Rails app and connect it to a Supabase Postgres database.' +author: thor_schaeff +image: getting-started/rails/rails.jpg +thumb: getting-started/rails/rails.jpg +categories: + - engineering +tags: + - postgres + - developers + - ruby +date: '2024-01-29' +toc_depth: 3 +--- + +Every Supabase project comes with a full [Postgres](https://www.postgresql.org/) database, a free and open source database which is considered one of the world's most stable and advanced databases. + +Postgres is an ideal choice for your Ruby on Rails applications as Rails ships with a built-in Postgres adapter! + +In this post we'll start from scratch, creating a new Rails project, connecting it to our Supabase Postgres database, and interacting with the database using the Rails Console. + + + +Supabase is one of the best [free alternatives to Heroku Postgres](/alternatives/supabase-vs-heroku-postgres). See [this guide](/docs/guides/resources/migrating-to-supabase/heroku) to learn how to migrate from Heroku to Supabase. + +There's also a [Heroku to Supabase migration tool](https://migrate.supabase.com/) available to migrate in just a few clicks. + + + +If you prefer video guide, you can follow along below. And make sure to subscribe to the [Supabase YouTube channel](https://www.youtube.com/channel/UCNTVzV1InxHV-YR0fSajqPQ?view_as=subscriber&sub_confirmation=1)! + +
+