Skip to content

Instantly share code, notes, and snippets.

@naterexw
Last active January 3, 2016 12:00
Show Gist options
  • Save naterexw/42bd74d7f3f4f7af18c9 to your computer and use it in GitHub Desktop.
Save naterexw/42bd74d7f3f4f7af18c9 to your computer and use it in GitHub Desktop.
Behavior Driven Development (BDD)
User Acceptance test (capybara)
Unit test (rspec)
Integration test
Stress test
Partial => Views
Helper =>
Method => Controller
====================
= Console commands =
====================
rails new . = initialize rails in current folder
rails new [name] = initailize rails with folder [name] with current directory
rails [command] -h = see help for rails [command]
rails server = starts rails server on localhost
rails console = starts rails console
bundle install = installs gems located in Gemfile
rails generate controller [name] [views name] = create [name] controller with [views name]
rails destroy controller [name] [views name] = destroy [name] controller with [views name]
rails generate model [model name] [name:string] [price:integer] = creates [model name] model DB, assigns [data:type]
rails destroy model [model name] = destroy [model name] model
rails generate migration [command] = generation migration file to run [command]
rails generate scaffold [model name] [name:string] [price:integer] = creates [model name] scaffold with [data:type]
rake -T = show rake help
rake db:reset = clears the DB (does rake db:drop + rake db:create + rake db:migrate) and runs migration on a fresh DB
rake db:create = creates the database for current environment
rake db:create:all = creates the databases for all envs
rake db:drop = drops the database for the current environment
rake db:drop:all = drops the databases for all envs
rake db:migrate = runs migration (up) for the current environment that have not run yet
rake db:migrate:status = shows migration history
rake db:seed = creates DB using seeds file
rake db:rollback = reverts (down) last DB migrate (only works with migration!)
rake db:schema:load = runs schema (state of DB as of last migration) file
rake db:schema:dump = dumps DB state into schema file
rake db:schema:damp = regenerate schema file
rails runner [filename.rb] = excecutes [filename] in rails environment
ruby [filename.rb] = excecutes [filename] in ruby environment
[DB name].all = list all records in DB
[DB name].where(key: true) = list all records where(key: true)
[DB name].where(key: true).last = list last record where(key: true)
[DB name].where(key: true).count = count of all records where(key: true)
raise = raises exception when running ruby code (in browser)
binding.pry = raises exception when running ruby code (in Rails console)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment