Commit 0ae8a90fa31be7cfe33415e931ea9f1a57c063be

Authored by Pius Uzamere
1 parent c103a4fa

fix for autoactivation

Showing 2 changed files with 7 additions and 3 deletions   Show diff stats
app/models/choice.rb
@@ -45,6 +45,7 @@ class Choice < ActiveRecord::Base @@ -45,6 +45,7 @@ class Choice < ActiveRecord::Base
45 45
46 #after_create :generate_prompts 46 #after_create :generate_prompts
47 def before_create 47 def before_create
  48 + puts "just got inside choice#before_create. is set to active? #{self.active?}"
48 unless item 49 unless item
49 @item = Item.create!(:creator => creator, :data => data) 50 @item = Item.create!(:creator => creator, :data => data)
50 self.item = @item 51 self.item = @item
@@ -53,7 +54,10 @@ class Choice < ActiveRecord::Base @@ -53,7 +54,10 @@ class Choice < ActiveRecord::Base
53 self.score = 0.0 54 self.score = 0.0
54 end 55 end
55 unless self.active? 56 unless self.active?
56 - question.should_autoactivate_ideas? ? self.active = true : self.active = false 57 + puts "this choice was not specifically set to active, so we are now asking if we should auto-activate"
  58 + self.active = question.should_autoactivate_ideas? ? true : false
  59 + puts "should question autoactivate? #{question.should_autoactivate_ideas?}"
  60 + puts "will this choice be active? #{self.active}"
57 end 61 end
58 return true #so active record will save 62 return true #so active record will save
59 end 63 end
app/models/user.rb
@@ -19,9 +19,9 @@ class User < ActiveRecord::Base @@ -19,9 +19,9 @@ class User < ActiveRecord::Base
19 visitor = visitors.find_or_create_by_identifier(visitor_identifier) 19 visitor = visitors.find_or_create_by_identifier(visitor_identifier)
20 raise "Question not found" if question.nil? 20 raise "Question not found" if question.nil?
21 if visitor.owns?(question) 21 if visitor.owns?(question)
22 - choice = question.choices.create!(choice_params.merge(:active => true, :creator => visitor)) 22 + choice = question.choices.create!(choice_params.merge(:active => false, :creator => visitor))
23 elsif question.local_identifier == choice_params[:local_identifier] 23 elsif question.local_identifier == choice_params[:local_identifier]
24 - choice = question.choices.create!(choice_params.merge(:active => true, :creator => visitor)) 24 + choice = question.choices.create!(choice_params.merge(:active => false, :creator => visitor))
25 else 25 else
26 choice = question.choices.create!(choice_params.merge(:active => false, :creator => visitor)) 26 choice = question.choices.create!(choice_params.merge(:active => false, :creator => visitor))
27 end 27 end