Application settings:
INSTALL POSTGRESQL
CHANGE database Configuration file in config/database.yml
with YOUR CREDENTIALS
-
Ruby version
- 2.5.1
-
Rails version
- 5.2.1
-
System dependencies
- rspec-rails - Testing framework. Rspec
- factory_girl_rails - Factory pattern for building objects
- shoulda_matchers - Provides RSpec with additional matchers.
- database_cleaner - Gem to clean our test database to ensure a clean state in each test suite.
- faker - A library for generating fake data.
-
Database creation AFTER CLONE REPOSITORY
- Prepare database (Create database, load schema and initialize seeds)
rails db:setup
-
Database initialization
- Load schema and initialize seeds
rails db:schema:load rails db:seed
-
Reset database
- Reset database
rails db:reset -> rails db:drop db:setup.
- Update schema file
rails db:schema:dump rails db:migrate:reset
-
Prepare database for test
rails db:test:prepare
- How to run the test suite
bundle exec rspec spec/ -fd --order rand
## Basic commands
rails g model NameModel attribute1:type attribute2:type ...
- this will create a model, migration, factory for model and model test file.
- example
rails g model Blog name:string status:boolean due_date:date days:integer
rails g migration AddConceptToJobs concept:references
rails db:migrate
rails db:rollback
generate controller with cli (model name in plural) and optional actions (index, show, new, update, destroy)
rails g controller Blogs index show
rails c
rails server