I have a Products table and want to add a column:
t.references :imageable, :polymorphic => true
I was trying to generate migration for this by doing:
$ rails generate migration AddImageableToProducts imageable:references:polymorphic
but I am obviously doing it wrong. Can anybody make any suggestion? Thanks
When I try to manually put it in after generating the migration, I did it like this:
class AddImageableToProducts < ActiveRecord::Migration
def self.up
add_column :products, :imageable, :references, :polymorphic => true
end
def self.down
remove_column :products, :imageable
end
end
and it still hasn't worked
:references{polymorphic}
. For example,rails generate migration AddImageableToProducts imageable:references:{polymorphic}
. Source – Footwall