- Ruby version
2.5.1
(we use rvm to manage ruby) - We use bundler to manage dependencies
- install bundler with
gem install bundler
- now run
bundle install
to install dependencies - install overcommit hooks by running
overcommit --install
overcommit --sign
overcommit --sign pre-commit
overcommit --sign pre-push
-
Install PostgreSQL (version >= 9.4) by following standard install steps
-
follow these instructions to properly add a user, replace
nb_user
with desired pg username andpass
with desired password for your user -
sudo -u postgres createuser nb_user
-
sudo -u postgres psql
-
postgres=#
ALTER USER nb_user CREATEDB;
-
postgres=#
ALTER USER nb_user WITH PASSWORD 'pass';
-
Create
database.yml
fromdatabase.yml.example
file and add your username and password
- run
bundle exec rails db:create db:schema:load db:seed
to create db and add seed data - run
bundle exec rails db:drop db:create db:schema:load db:seed
to drop current db and start fresh
We use Rspec with factory_bot for testing
- run
bundle exec rspec
to run full test suite - run
bundle exec rspec <test-file/folder>
to run parts of suite - add
-fd
flag to run test with formatted output
- If you want to play around, console with
rails console
orrails c
- add
byebug
to add breakpoint and debug, see byebug cheat sheet - Start server with
rails server
orrails s
- running
rails dbconsole
will drop you into psql/db prompt - run
rails routes
to see all possible routes to query(or see controller specs to see what params they take). - run
rails db:migrate
to run migration - run
rails db:migrate:status
to see state to db and pending migrations - run
rails db:rollback
to undo last migration