Skip to content

Instantly share code, notes, and snippets.

@wilsonsilva
Created February 11, 2015 13:59
Show Gist options
  • Select an option

  • Save wilsonsilva/975017def0ebb33729dc to your computer and use it in GitHub Desktop.

Select an option

Save wilsonsilva/975017def0ebb33729dc to your computer and use it in GitHub Desktop.
Rails Migration Cheat Sheet
bundle exec rails g migration AddUserRefToProducts user:references
# Generates
class AddUserRefToProducts < ActiveRecord::Migration
def change
add_reference :products, :user, index: true
end
end
# Running it will create a user_id column on products and an index on products table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment