我用Ryan Bates的source code for railscasts#141创建了一个简单的购物车.在其中一次迁移中,他列出了
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.belongs_to :category
t.string :name
t.decimal :price
t.text :description
t.timestamps
end
end
def self.down
drop_table :products
end
end
以下是产品型号:
class Product < ActiveRecord::Base
belongs_to :category
end
t.belongs_to :category
线是多少?这是t.integer category_id
的别名吗?