我有一个 Products 表并想添加一列:
t.references :imageable, :polymorphic => true
我试图通过执行以下操作为此生成迁移:
$ rails generate migration AddImageableToProducts imageable:references:polymorphic
但我显然做错了。有人可以提出任何建议吗?谢谢
当我在生成迁移后尝试手动放入时,我是这样做的:
class AddImageableToProducts < ActiveRecord::Migration
def self.up
add_column :products, :imageable, :references, :polymorphic => true
end
def self.down
remove_column :products, :imageable
end
end
它仍然没有工作