Commit 439c42104b6fee90a63fa2422f212eaf32cdc281

Authored by Dhruv Kapadia
1 parent 8d5da83c

Copying creator information from Item model

db/migrate/20100621162849_add_creator_to_choices.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +class AddCreatorToChoices < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :choices, :creator_id, :integer
  4 + Choice.find(:all, :include => [:item]).each do |c|
  5 + c.creator_id = c.item.creator_id
  6 + c.save
  7 + end
  8 + end
  9 +
  10 + def self.down
  11 + remove_column :choices, :creator_id
  12 + end
  13 +end
... ...
spec/models/choice_spec.rb
... ... @@ -4,8 +4,7 @@ describe Choice do
4 4  
5 5 it {should belong_to :question}
6 6 it {should belong_to :item}
7   - #uncomment after adding creator to choice model
8   - #it {should belong_to :creator}
  7 + it {should belong_to :creator}
9 8 it {should have_many :flags}
10 9 it {should have_many :votes}
11 10 it {should have_many :prompts_on_the_left}
... ...