2012-10-20 72 views

回答

11

通过与控制台创建一个新的迁移:

rails g migration add_amount_to_items 

这应该创建一个迁移是这样的:

class AddAmountToItems < ActiveRecord::Migration 
    def change 
    # add_column table_name, :column_name, :column_type 
    add_column :items, :amount, :integer 
    end 
end 
6

偷懒的方法:

rails g migration add_amount_to_items amount:integer 
+0

你好谢谢@ WeGoingNowhere - 什么是适当的,舒适的方式可以长期保存悲伤。如果你不想'快速和肮脏的' – BKSpurgeon

+0

并且不要忘记运行迁移:bin/rake db:migrate – Arthur