Show Menu
Cheatography

Ruby on Rails projects Cheat Sheet (DRAFT) by

Guidelines to follow when building a Ruby on Rails project

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Instal­lation

Install Ruby (incl. Devkit)
Install Rails
gem install rails
Install git

Verify installed version

Verify Ruby version
ruby -v
Verify Rails version
rails -v
Verify git version
git --version

Create a new project

Select directory
cd <di­rec­tor­y>
Create new Rails project
rails new <pr­oje­ct_­nam­e>
Select new project directory
cd <pr­oje­ct_­nam­e>
Create and migrate database
rails db:prepare
Initialize a new Git repository for version control
git init
Add all files Git staging area
git add .
Commit staging files to Git repository
git commit -am "­Initial commit­"
You've now created a project and committed it to a Git reposi­tory. Additi­onally, you could also set up a remote repository on GitHub.

Generate a model

Generate model
rails generate model <mo­del­_na­me> <at­tri­but­e1>­:<t­ype> <at­tri­but­e2>­:<t­ype>
Apply migration and create table
rails db:migrate