diff --git a/db/migrate/20100621162849_add_creator_to_choices.rb b/db/migrate/20100621162849_add_creator_to_choices.rb new file mode 100644 index 0000000..094e522 --- /dev/null +++ b/db/migrate/20100621162849_add_creator_to_choices.rb @@ -0,0 +1,13 @@ +class AddCreatorToChoices < ActiveRecord::Migration + def self.up + add_column :choices, :creator_id, :integer + Choice.find(:all, :include => [:item]).each do |c| + c.creator_id = c.item.creator_id + c.save + end + end + + def self.down + remove_column :choices, :creator_id + end +end diff --git a/spec/models/choice_spec.rb b/spec/models/choice_spec.rb index 54348a4..0b2b6ca 100644 --- a/spec/models/choice_spec.rb +++ b/spec/models/choice_spec.rb @@ -4,8 +4,7 @@ describe Choice do it {should belong_to :question} it {should belong_to :item} - #uncomment after adding creator to choice model - #it {should belong_to :creator} + it {should belong_to :creator} it {should have_many :flags} it {should have_many :votes} it {should have_many :prompts_on_the_left} -- libgit2 0.21.2