Show Menu
Cheatography

Rails4 Model&Migration Generator (WorkInProgress) Cheat Sheet by

A cheatsheet for rails 4 model and migration generator

Basic Migration Generation

Migration Type
Command
prepended by 'rails generate migration '
Add XXX To Table YYY
AddXXX­ToYYY [CCC CCC ...]
Remove XXX From Table YYY
Remove­XXX­ToYYY [CCC CCC ...]
Create Table YYY
CreateYYY [CCC CCC ...]
Add References to Table YYY
AddOOO­Ref­ToYYY
Create Join Tables
Create­Joi­nTa­ble­YYYZZZ
XXX - Migration Name
YYY - Table Name
ZZZ - Second Table Name
OOO - object reference
CCC - Column Combos. Refer to column tables for possib­lities

Basic Model Generation

Model Type
Command
prepended by 'rails generate model '
Basic Model
XXX [CCC CCC ...]

Migration Scheme Methods

rename­_column <ta­ble­>, <ol­d_c­olu­mn>, <ne­w_c­olu­mn>
 

Column Combos

Basic Column
NNN:TTT
Indexed Column
NNN:TT­T:index
NNN - Column Name
TTT - Column Type. Refer to Types for possib­ilities

Types

:binary
:boolean
:date
:datetime
:decimal
:float
:integer
:prima­ry_key
:refer­ences
:string
:text
:time
:timestamp
------ PostgreSQL Specific Types -------
:hstore
:json
:array
:cidr_­address
:ip_ad­dress
:mac_a­ddress
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

            Ruby on Rails Cheat Sheet by Dave Child and addedbytes.com
          Conceptual Database Design Cheat Sheet
          Contentful Migration Cheat Sheet

          More Cheat Sheets by Wayland He