views:

247

answers:

3

I have the folowing migration but don't know what to use in the down method

    change_table :addresses do |t|
      t.references :addressable, :polymorphic => true
    end
A: 

What's wrong with this?

def self.down
  remove_column :addresses, :addressable
end
Mark A. Nicolosi
Thats what I thought it would be but this is the first time i have used polymorphic models and got confused
Damian
actually it shouldn't it be remove_column :addresses, :addressable
Damian
Oops, you're totally right. I should have checked the docs first, instead of going by memory.
Mark A. Nicolosi
+1  A: 

What's the problem?

def self.down
  remove_column :addresses, :addressable_type
  remove_column :addresses, :addressable_id
end
Leonid Shevtsov
are you saying remove_column :addresses, :addressable is not correct?
Damian
yeah.. this is the right solution
amikazmi
Damian: no, just look at the table via some SQL browser and you will see the two columns.
Leonid Shevtsov
+1  A: 

actually,

   change_table :addresses do |t|
     t.remove_references :addressable
   end

would be a bit railsier, no?

rbxbx