I was using Ryan Bates\'s source code for railscasts #141 in order to create a simple shopping cart. In one of the migrations, he lists
class CreateProducts
$ rails g migration AddUserRefToProducts user:references
this generates:
class AddUserRefToProducts < ActiveRecord::Migration def change add_reference :products, :user, index: true end end
http://guides.rubyonrails.org/active_record_migrations.html#creating-a-standalone-migration