我有一个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
但它仍然没有起作用
https://stackoverflow.com/questions/5534579
复制相似问题