Skip to content

ita-social-projects/ZeroWaste

Repository files navigation

SoftServe IT Academy

ZERO WASTE

1. About the project

zero-waste

Zero Waste Lviv is a Public Organization that works on the implementation of waste reduction principles in Lviv and Ukraine. Organization draws attention of the city and businesses by conducting trainings, meetings, workshops and research to support ‘zero waste’ grounds. Organization conducts a campaign to draw attention to the problem of using disposable hygiene products for women and children and possible ways or reduction. Website - https://zerowastelviv.org.ua

In order to attract attention to financial and ecological consequences of disposable diaper usage it is planned to create a module that will calculate budget spent on diapers and calculations of the future expenses. As visual representation it is planned to show the volume of waste that was made during usage of disposable diapers for one child.

Deployed Apps and Environments

The latest version from the 'develop' branch is automatically deployed to stage environment in Render, staging link. The latest version from the release branch 'master' is automatically deployed to Production environment, production link.

Installation

  • Start the project locally

Required to install

  • Ruby 3.2.2
  • Ruby on Rails 7.1.2
  • PostgreSQL 12
  • Puma as a web server
  • Yarn
  • jQuery
  • Bootstrap

Clone

$ git clone https://github.com/ita-social-projects/ZeroWaste.git

Local setup

First of all you need RVM to setup project. For the operating system Windows the optimal solution is to use WSL.

$ bin/setup or $ bundle install

PostgreSQL

Install PostgreSQL for your operating system or subsystem. You can familiarize yourself with PostgreSQL documentation.

In your local machine in cloned project in config folder rename database.yml.sample to database.yml. Make sure that the user and password match the data in this file. Port may be changed.

For further work, make sure that you have a user 'postgres' with superuser. If is no that one do next: $ sudo -u user psql user $ CREATE USER postgres SUPERUSER; $ CREATE DATABASE postgres WITH OWNER postgres;

If you're having trouble authenticating, you may need to reset your password. You can read instruction how to do it.

pg gem

Under certain circumstances bundle can do not install pg.

To install manually: $ sudo apt-get install libpq-dev then $ gem install pg

Database configure

For correct operation of the migration, you need to rename the migration file 20220123171144_create_versions.rb so that it is processed first.

To create the necessary databases and update them:

$ rake db:create then $ rake db:migrate

$ rake db:reset can resolve some errors connected with database.

Redis

You need Redis for correct work. Install Redis for your operating system or subsystem. You can familiarize yourself with Redis documentation.

Installation for Ubuntu:

$ curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

$ sudo apt-get update $ sudo apt-get install redis

npm and Node.js

Also you need Node.js. Install npm and Node.js for your operating system or subsystem. You can familiarize yourself with npm and Node.js documentation

yarn

You can read more about yarn there: yarn documentation.

Installation: $ npm install --global yarn

Webpacker

To prevent an error when starting the server install webpacker. You can read more about webpacker there: Webpacker documentation.

Installation: $ yarn add @rails/webpacker $ bundle update webpacker

Sidekiq

Simple, efficient background processing for Ruby. You can read more about sidekiq there: Sidekiq documentation.

Installation: $ bundle add sidekiq

How to run local

  1. Open terminal. In some systems, after restarting them, the postgresql server remains disabled, perhaps at the first start you should enter sudo service postgresql start.
  2. Run rails server/rails s to start application
  3. Open http://localhost:3000 to view it in the browser.

Solutions when an errors occurs: psql: FATAL: role "postgres" does not exist

If you have Webpacker::Manifest::MissingEntryError you can try next steps: $ rm -rf node_modules $ rails webpacker:install $ yarn install

Usage

How to run Rubocop

Running rubocop with no arguments will check all Ruby source files in the current folder:

$ rubocop

Alternatively you can pass rubocop a list of files and folders to check:

$ rubocop app spec lib/something.rb

For more details check the available command-line options:

$ rubocop -h

Git-hook pre-commit

Before using git-hook-pre-commit you need to install sudo apt-get install cmake

For using git-hook-pre-commit type cp git-hooks/pre-commit .git/hooks/pre-commit command to install your hook.

Run git commit -m "name" to commit changes locally. If you have some troubles with style conventions after running git commit -m "name", you need to run rubocop -a or rubocop -A. Each of these commands can resolve the majority of warnings.

Type git commit -m "name" --no-verify for commiting without formating.