Rails Migrations

Automatic Generation

Add Column

String

rails g migration add_column_to_product name:string
rails g migration add_column_to_product name

Integer

rails g migration add_column_to_product available:integer

Description

rails g migration add_column_to_product name:text

Date Time

rails g migration add_column_to_product name:datetime

Unique Index

rails g migration add_column_to_product some_id:integer:uniq

Manual Migrations

Remove Field

remove_column :table, :column

Add Index

add_index :table, :column

Add Unique Index

add_index :table, [:column_1, :column_2], unique: true

 Faker

Installing

gem install faker

Usage

Faker::Name

Faker Code Sample Output
Faker::Name.name Georgette Frami
Faker::Name.first_name Caleb
Faker::Name.last_name Bernhard
Faker::Name.prefix Mr.
Faker::Name.suffix III
Faker::Name.title Principal Functionality Planner

Faker::Address

Faker Code Sample Output
Faker::Address.city Botsfordview
Faker::Address.street_name Irving Garden
Faker::Address.street_address 28228 Cormier Route
Faker::Address.secondary_address Suite 733
Faker::Address.building_number 734
Faker::Address.zip_code 81189-0163
Faker::Address.zip 84813

Faker::Lorem

Faker Code Sample Output
Faker::Lorem.word fuga
Faker::Lorem.words ["commodi", "quia", "eligendi"]
Faker::Lorem.words(5) ["quo", "error", "velit", "neque", "dicta"]
Faker::Lorem.sentence Ut sit rerum reprehenderit ut quae sunt sed.
Faker::Lorem.sentences(5) ["Praesentium fugit iste voluptate mollitia animi.", "Necessitatibus tenetur laboriosam aliquam.", "Esse aperiam quas ex.", "Alias consectetur illo.", "Sapiente aspernatur sint dolorum voluptas."]

Faker::Internet

Faker Code Sample Output
Faker::Internet.email macey@price.com
Faker::Internet.email(‘teejay’) “teejay@mcclure.net”
Faker::Internet.free_email rodolfo.schimmel@hotmail.com
Faker::Internet.free_email(‘teejay’) teejay@yahoo.com