How To Use PostgreSQL with Your Ruby on Rails Application

preview_player
Показать описание
When using the Ruby on Rails web framework, your application will use SQLite as a database by default. SQLite is a lightweight, portable, and user-friendly relational database that performs especially well in low-memory environments, so it will work well in many cases. However, for highly complex applications that need more reliable data integrity and programmatic extensibility, a PostgreSQL database will be a more robust and flexible choice. You will need to perform additional steps to configure your Ruby on Rails setup to use PostgreSQL.

In this tutorial, you will set up a Ruby on Rails development environment connected to a PostgreSQL database on an Ubuntu 20.04 server

Commands used
rails new appname -d=postgresql
cd appname

echo 'export APPNAME_DATABASE_PASSWORD="PostgreSQL_Role_Password"' ~/.bashrc

source ~/.bashrc

WRITE IN
username: sammy
password: %= ENV['APPNAME_DATABASE_PASSWORD'] %

OUT OF NANO
rails db:create
rails server --binding=server_public_IP

Useful links
Рекомендации по теме