Skip to content

Instantly share code, notes, and snippets.

@at1as
Created July 16, 2015 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save at1as/c8f58e7f5d2370ca7067 to your computer and use it in GitHub Desktop.
Save at1as/c8f58e7f5d2370ca7067 to your computer and use it in GitHub Desktop.
Rails Basic Commands

Create Controller

  • rails generate controller Users new

Generate Model (also creates a migration)

  • rails generate model User name:string email:string

Create Migration

  • rails generate migration AddPartNumberToProducts part_number:string

Add Model Reference to Model (ex. Article to User)

  • rails generate migration AddArticleRefToUser user:references

Migrate Database

  • bundle exec rake db:migrate

Rebuild Database from Scratch (Clear all data)

  • rake db:schema:load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment