Skip to content

Instantly share code, notes, and snippets.

@jshawl
Last active April 23, 2017 06:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jshawl/ce1de309ef993ec808d9 to your computer and use it in GitHub Desktop.
Save jshawl/ce1de309ef993ec808d9 to your computer and use it in GitHub Desktop.

Common Rails Commands

rake db:create

  • Creates all the databases specified in config/database.yml

rake db:migrate

  • Run existing migrations in db/migrate
  • Generates the schema.rb file

rake db:seed

  • Runs db/seeds.rb

rake db:drop

  • Drop the current environment’s database

rake db:drop:all

  • Drop all databases listed in config/database.yml

rake db:migrate:reset

  • Drop tables, create tables, rerun all migrations.

rake routes

  • List all available routes, defined in config/routes.rb

rails generate migration

  • syntax: rails g migration ModelName title:string

rails generate model

  • syntax: rails g model ModelName

rails console

  • The rails version of pry.
  • Useful for viewing data in db, and testing model methods

rails new

  • create a new rails application
  • use rails new AppName -d postgresql

rails server

  • Starts the server (ctrl-c to stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment