Commit 439c42104b6fee90a63fa2422f212eaf32cdc281
1 parent
8d5da83c
Exists in
master
and in
1 other branch
Copying creator information from Item model
Showing
2 changed files
with
14 additions
and
2 deletions
Show diff stats
@@ -0,0 +1,13 @@ | @@ -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,8 +4,7 @@ describe Choice do | ||
4 | 4 | ||
5 | it {should belong_to :question} | 5 | it {should belong_to :question} |
6 | it {should belong_to :item} | 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 | it {should have_many :flags} | 8 | it {should have_many :flags} |
10 | it {should have_many :votes} | 9 | it {should have_many :votes} |
11 | it {should have_many :prompts_on_the_left} | 10 | it {should have_many :prompts_on_the_left} |