This README documents the steps necessary to get the metrics-api Ruby on Rails application up and running locally.
This describes all that you need to make the app run successfully.
This includes all infrastructure dependencies (besides nvm). To install these required items, first, make sure you have homebrew installed and set up. Afterward, run the following command in the root of the repository:
brew bundle
Install rbenv and Ruby 2.7.6.
rbenv init
rbenv install 2.7.6
Install nvm and Node 16.13.1
Install yarn
via npm install --global yarn (in your node's version)
or
via homebrew brew install yarn
Put PostgreSQL on the path (zsh example):
echo 'export PATH="/opt/homebrew/opt/postgresql@12/bin:$PATH"' >> ~/.zshrc
To run on startup:
# to have launchd start postgresql now and restart at login
brew services start postgresql@12
brew services stop postgresql@12
brew services restart postgresql@12
git clone [email protected]:azizmashkour/metrics-api.git && cd metrics-api
Run rake tasks to create the schema and run any pending migrations.
bundle exec rake db:setup
bundle exec rake db:migrateTo add test data in development, run:
bundle exec rake db:seed
This will create a list of fake metrics to be populated and used in the Chart.js graph. Once this command is executed, the next time you may try to run it again, it automatically update the existing data instead of deleting them.
Since we are using some yarn packages and ruby gems, we need to install all of them by running the commands:
gem install bundler
bundle install
yarn install
To start the web server, run this command:
bundle exec rails server
Then open your browser to http://localhost:3000. You should see the home page of the metrics Api.
If your CSS is not loaded, ensure the run these commands and restart your server:
./bin/bundle add tailwindcss-rails
./bin/rails tailwindcss:install
There are some other common commands you'll want to run:
bundle exec rails console # interactive console
tail -f log/development.log
To run the tests, run this command:
bundle exec rake spec
or
bundle exec rails spec
To set up the test databases needed to run:
RAILS_ENV=test bundle exec rake db:setup