需要在数据库中添加一个字段
我先运行ruby script/generate migration add_price
然后打开迁移任务的源文件,修改其中的up()方法,想表products中添加price字段。down()方法删除这个字段
class AddPrice < ActiveRecord::Migration
def self.up
add_column :products, :decimal, :precision =>8, :scale=>2, :default=>0
end
def self.down
remove_column :products, :price
end
end
运行数据迁移:
rake db:migrate

add_column :products, :decimal, :precision =>8, :scale=>2, :default=>0
rake aborted!
You have a nil obiect when you didn't expect it!
You might have expexted an instance of Array.
The error occurred while eva
luating nil.[]
请问有啥解决方案?
[
本帖最后由 ppdai 于 2007-11-5 23:55 编辑 ]