Instinct API is the API for a music streaming/downloading platform, Instinct.
Before you start, ensure you have met the following requirements:
- Ruby 3.3.1: Install guide: Ruby
- Ruby on Rails 7.1.3: Install guide: Rails
- PostgreSQL 14: Install guide: PostgreSQL.
Before starting the setup, ensure you have the required prerequisites/dependencies
Download the project files or clone the project repository to your local machine
Install bundler by using gem install bundler
Inside the projects main directory (where 'Gemfile' is) run: bundle install
To set postgresql start on boot: sudo systemctl enable postgresql
populate database after initial postgres install if not done already: sudo postgresql-setup --initdb --unit postgresql
To start postgresql server manually: sudo systemctl start postgresql
or sudo service postgresql start
Setup Database credentials by creating a .env file at the root of the project. Insert these ENV variables:
PG_USERNAME=postgres
PG_PASSWORD=postgres
PG_HOST=localhost
PG_PORT=5432
Replace these credentials with your information unless you are using the default postgres user (you may need to set the password for user postgres, see troubleshooting)
Create Database: rails db:create
Initialize Database: rails db:migrate
Generate your credential files: rails credentials:edit
and save the generated file
Start the rails server using: rails server
Error: An error occurred while installing pg (1.5.6), and Bundler cannot continue.
Fix: Try installing PostgreSQL client development libraries:
Debian:
sudo apt install libpq-dev
Fedora:
sudo dnf install postgresql-devel
__
Error: authentication failed for user "postgres" when running rails db:create (for default postgres user)
Fix: set the password: sudo -i -u postgres
then psql
then ALTER USER postgres WITH PASSWORD 'yourpassword';