C
C
Cody452021-10-06 21:15:48
PostgreSQL
Cody45, 2021-10-06 21:15:48

What is the order of installing PostgreSQL for ruby ​​on rails?

Good day.
Please tell me how to install or connect PostgreSQL for ruby ​​on rails.
I have already installed:
Ruby
SQLite3
Node.js
Yarn
rails
Created a new application. (I have the app on my D drive)
But as I found out, Rails uses a SQLite database by default, which Heroku doesn't support.
I installed postgreSQL (default installation location, C drive), how do I switch to it?
I read about the -d postgresql flag. Should it be added when creating a new rails application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2021-10-06
@2ord

Run the command for help:
rails new -h
You can create a new empty application with a key -d postgresqland transfer the setting from there.
Or just copy the file from here , customizing it to your needs.
After that, you need to remove 'sqlite3' from the Gemfile and add 'pg' instead. After that execute bundle install. And don't forget to commit the changes to git.
You also need to install the libpq package (if Linux), otherwise the 'pg' gem will not install.
For Heroku, also read:
https://devcenter.heroku.com/articles/rails-databa...
https://devcenter.heroku.com /articles/heroku-postgresql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question