Commit 739bcd4cb163210716a2b8dad39df493d234802d

Authored by Ábner Silva de Oliveira
1 parent 1b00d7f2

added creator_identifier to choices index action result and fixed Vote default s…

…cope (error in boolean field in postgres database)
app/controllers/choices_controller.rb
@@ -29,7 +29,7 @@ class ChoicesController < InheritedResources::Base @@ -29,7 +29,7 @@ class ChoicesController < InheritedResources::Base
29 end 29 end
30 end 30 end
31 index! do |format| 31 index! do |format|
32 - format.xml { render :xml => @choices.to_xml(:only => [ :data, :score, :id, :active, :created_at, :wins, :losses], :methods => :user_created)} 32 + format.xml { render :xml => @choices.to_xml(:only => [ :data, :score, :id, :active, :created_at, :wins, :losses], :methods => [:user_created, :creator_identifier])}
33 end 33 end
34 34
35 end 35 end
app/models/choice.rb
@@ -81,6 +81,10 @@ class Choice < ActiveRecord::Base @@ -81,6 +81,10 @@ class Choice < ActiveRecord::Base
81 self.creator_id != self.question.creator_id 81 self.creator_id != self.question.creator_id
82 end 82 end
83 83
  84 + def creator_identifier
  85 + self.creator.identifier
  86 + end
  87 +
84 def compute_bt_score(btprobs = nil) 88 def compute_bt_score(btprobs = nil)
85 if btprobs.nil? 89 if btprobs.nil?
86 btprobs = self.question.bradley_terry_probs 90 btprobs = self.question.bradley_terry_probs
app/models/vote.rb
@@ -19,7 +19,7 @@ class Vote < ActiveRecord::Base @@ -19,7 +19,7 @@ class Vote < ActiveRecord::Base
19 named_scope :active, :include => :choice, :conditions => { 'choices.active' => true } 19 named_scope :active, :include => :choice, :conditions => { 'choices.active' => true }
20 named_scope :active_loser, :include => :loser_choice, :conditions => { 'choices.active' => true } 20 named_scope :active_loser, :include => :loser_choice, :conditions => { 'choices.active' => true }
21 21
22 - default_scope :conditions => "#{table_name}.valid_record = 1" 22 + default_scope :conditions => {"#{table_name}.valid_record" => true }
23 23
24 serialize :tracking 24 serialize :tracking
25 25