-
Install Postgres
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
-
Create database user
$ sudo -u postgres createuser -s pguser
-
Set database user password
$ sudo -u postgres psql
postgres=# \password pguser
postgres=# \q
-
Install
rbenv
using this guide -
Install
ruby-build
using this guide -
Install ruby and bundler
$ rbenv install 2.4.2
Attention:
JavaScript runtime is needed to run app, e.g. NodeJS (apt-get install nodejs
)
For other supported runtimes see https://github.com/rails/execjs
Go to directory where you have cloned the repository.
-
Prepare
.env
configuration file
$ cp .env.example .env
-
Add
.env
with data:RAILS_MAX_THREADS = 1 DATABASE_HOST = localhost DATABASE_USER = pguser DATABASE_PASSWORD = YOUR_PASSWORD
-
Install required gems
$ gem install bundler
$ bundle install
-
Create database
$ bin/rails db:create
In case PG::Error: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
error, follow the instructions
-
Migrate database
$ bin/rails db:migrate
-
Seed database
$ bin/rails db:seed
-
Drop, create, migrate and seed database
$ bin/rails db:drop db:create db:migrate db:seed
-
Get records from database (in example get records which have association with shipper, customer, employee)
$ bin/rails console
or$ bin/rails c
irb(main):001:0> Order.where.not(ship_via: nil, customer_id: nil, employee_id: nil)