You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/ruby-on-rails/baseline.md
+44-25Lines changed: 44 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ weight: 5
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Set up Ruby on Rails with PostgreSQL on SUSE Arm64
9
+
## Overview
10
10
11
11
Follow these steps to install PostgreSQL, connect it to a Ruby on Rails app, and verify everything works on a SUSE Arm64 Google Cloud C4A VM.
12
12
@@ -127,9 +127,9 @@ development:
127
127
## Change the Authentication Method
128
128
By default, PostgreSQL on many Linux distributions (including SUSE) uses the ident authentication method for local connections. This method maps Linux system usernames directly to PostgreSQL roles. While convenient for local access, it prevents password-based authentication, which is necessary for Rails and most application connections.
129
129
130
-
To allow Rails to connect using a username and password, change the authentication method in PostgreSQL’s configuration file `pg_hba.conf` from ident to md5.
130
+
To allow Rails to connect using a username and password, change the authentication method in PostgreSQL’s configuration file `pg_hba.conf` from ident to md5:
131
+
131
132
132
-
Open your configuration file
133
133
```console
134
134
sudo vi /var/lib/pgsql/data/pg_hba.conf
135
135
```
@@ -220,10 +220,25 @@ In the PostgreSQL shell, run:
220
220
\d tasks
221
221
\q
222
222
```
223
+
Connect to PostgreSQL as the database superuser and inspect the table structure:
224
+
225
+
```console
226
+
sudo -u postgres psql
227
+
```
228
+
229
+
In the PostgreSQL shell, connect to your Rails development database and examine the tasks table:
230
+
231
+
```console
232
+
\c db_test_rubyapp_development
233
+
\d tasks
234
+
\q
235
+
```
236
+
237
+
This sequence of commands does the following:
223
238
-`sudo -u postgres psql` → Launches the PostgreSQL shell as the superuser `postgres`.
224
-
-`\c db_test_rubyapp_development` → Connects to the Rails app’s development database.
239
+
-`\c db_test_rubyapp_development` → Connects to the Rails app's development database.
225
240
-`\d tasks` → Displays the schema (columns and types) of the `tasks` table.
226
-
- `\q → Exit from the PostgreSQL shell
241
+
-`\q` → Exit from the PostgreSQL shell.
227
242
228
243
You should see output similar to:
229
244
```output
@@ -245,43 +260,47 @@ Indexes:
245
260
"tasks_pkey" PRIMARY KEY, btree (id)
246
261
```
247
262
248
-
## Open port 3000 in Google Cloud (VPC firewall)
249
-
Before proceeding to run the Rails server, you need to allow port 3000 from your GCP console. Below are the steps to do that:
263
+
## Configure Google Cloud firewall to allow port 3000
264
+
265
+
Your Rails app runs on port 3000 by default. To access it from your browser, you need to configure Google Cloud's firewall to allow incoming connections on this port.
250
266
251
-
a. On the GCP console, navigate to **Firewall** -> **Create Firewall Rule**
267
+
Navigate to the firewall settings in your Google Cloud Console:
268
+
269
+
- Open the **Navigation menu** (hamburger icon in the top left)
270
+
- Go to **VPC network** → **Firewall**
271
+
- Click **Create Firewall Rule**
252
272
253
-

273
+

254
274
255
-
b. Fill in the details as below:
275
+
Fill in the details as below:
256
276
257
-
Give a **name** for your desired port (e.g., `allow-3000-ingress`).
277
+
- Provide a **name** for your desired port (for example, `allow-3000-ingress`).

260
280
261
281
262
-
Set **Direction of Traffic** to **"Ingress"**.
282
+
-Set **Direction of Traffic** to **Ingress**.
263
283
264
-
Set **Target** to **"All Instances in the Network"**. You can also choose**"Specific Tags"**.
284
+
-Set **Target** to **All Instances in the network**. You can also select**Specific Tags**.
265
285
266
-
Set the **Source IPv4 range** to **"0.0.0.0/0"**, for global access.
286
+
-Set the **Source IPv4 range** to `0.0.0.0/0`, for global access.
267
287
268
-

269
-
270
-
In the **"Protocols and Ports"**, click on **"TCP"**, and mention the port number **"3000"**.
288
+

289
+
In the **Protocols and ports** section, select **TCP** and enter `3000` in the port field:
271
290
272
-

291
+

273
292
274
293
275
-
Click on**"Create"**. The Firewall rule will be created successfully and can be viewed in the Firewall Policies Page:
294
+
- Select**Create**. Your firewall rule is created and appears in the Firewall policies page:

278
297
279
298
## OS firewall (firewalld) on SUSE
280
299
Once done, go back to your VM, install FirewallD:
281
300
```console
282
301
sudo zypper install firewalld
283
302
```
284
-
Now start FirewallD and execute the commands to allow port 3000:
303
+
Now start FirewallD and run the commands to allow port 3000:
285
304
286
305
```console
287
306
sudo systemctl start firewalld
@@ -296,18 +315,18 @@ Now that port 3000 is allowed in your VM’s ingress firewall rules, you can sta
296
315
```console
297
316
rails server -b 0.0.0.0
298
317
```
299
-
-This command lets you access Rails from your browser using the VM’s external IP.
318
+
This command lets you access Rails from your browser using the VM’s external IP.
300
319
301
320
302
321
## Access the Rails application:
303
-
Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar:
322
+
Open a web browser on your local machine and enter the following URL in the address bar:
304
323
305
324
```
306
325
http://[YOUR_VM_EXTERNAL_IP]:3000
307
326
```
308
327
- Replace `<YOUR_VM_PUBLIC_IP>` with the public IP of your GCP VM.
309
328
310
-
You will see a Rails welcome page in your browser if everything is set up correctly. It looks like this:
329
+
You will see a Rails welcome page in your browser if everything is set up correctly, as shown below:
311
330
312
331

0 commit comments