Roastrails is an imaginary coffee bean store built to test the functionality of Rails 7. This repository contains all the necessary information to set up and run the project.
To set up the Ruby and Rails environment, follow these steps:
- Install the required dependencies by running the following command:
sudo apt install -y build-essential git libsqlite3-dev redis ruby-dev tzdata
- Install
rbenv
by running the following command:
sudo apt install rbenv
- Initialize
rbenv
by running the following command:
rbenv init
- Install Ruby version 3.1.3 by running the following command:
rbenv install 3.1.3
- Set the global Ruby version to 3.1.3 by running the following command:
rbenv global 3.1.3
- Install Rails version 7.0.4 by running the following command:
gem install rails -v 7.0.4 --no-document
To run the Roastrails project in dev, use the following command in the root directory:
bin/dev
To run the Roastrails project in a server, use the following command:
rails server
This will start the server and make the application accessible.
To run all of the tests for the Roastrails project, use the following command:
rails test
To run tests for e.g. models and so forth use:
rails test:models
To manage the database for the Roastrails project, you can use the following commands:
-
To migrate the database, run the following command:
rails db:migrate
-
To seed the database with initial data, run the following command:
rails db:seed
-
To rollback the last database migration, run the following command:
rails db:rollback
-
To rollback and reapply the last database migration, run the following command:
rails db:migrate:redo