1

I'm using Rails 7.0.4 and Ruby 3.0.2.

The first time I tried to deploy, I understood that I needed to start by using Redis and PostgreSQL. In one of the videos on Youtube, I learned that I should create a Procfile with the command line web: rake db:migrate && bin/rails server -b 0.0.0.0 -p {PORT: -3000}. After that, I put the application on GitHub and then selected the application on Railway to deploy it. Then, I received an error that apparently got resolved when I changed {PORT: -3000} to PORT, as suggested in the comments of one of the videos. I also saw that I should create a railway.json file with the following configuration:

{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}

After that, the error message was different this time: "crashed". Then, while watching another video, I learned that I should add some parameters to the configurations on the Railway website, specifically under "variables > RAW Editor". Some of the parameters were:

DATABASE_URL=postgresql://${{ PGUSER }}:{{ PGPASSWORD }}@${{ PGHOST }}:${{ PGPORT }}/${{ PGDATABASE }}
LANG=en_US.UTF-8
PGDATABASE=railway
PGHOST=containers-us-west-77.railway.app
PGPASSWORD=*********
PGPORT=******
PGUSER=postgres
PORT=3000
RACK_ENV=production
RAILS_ENV=production
RAILS_MASTER_KEY=***********
RAILS_MAX_THREADS=5
REDIS_URL=*********

However, I received the "Crashed" error again, and in the data log, the error was URI::InvalidURIError: bad URI(is not URI?): postgresql://postgres:{{ PGPASSWORD }}@containers-us (...).

Before posting this question here, I searched for any similar ones and found the post at Deploying Ruby on Rails apps to Railway. But, the answer to that post states all the files should have this permission set: -rwxr-xr-x, and mine already are.

Looking at the PGPASSWORD in the RAW Editor ENV and PGPASSWORD in Postgres connect, they are the same. My main question is: In the Gemfile, the database for Active Record is set as "gem 'sqlite3', '1.4'". Does that have something to do with it? Should I be using PostgreSQL instead?

sonali
  • 762
  • 10
  • 23
Philipe
  • 11
  • 1
  • Yes you need to use the pg gem to use a Postgres database – dbugger May 17 '23 at 23:27
  • thankss, I used the postgres gem, and I can use the application locally with rails s, but when I try to deploy it, I receive the crash error again. This time, I think it may be a problem with the database.yml file, and I am researching about it. – Philipe May 18 '23 at 12:18

0 Answers0