diff --git a/app/models/skip.rb b/app/models/skip.rb index 596055b..009bb0e 100644 --- a/app/models/skip.rb +++ b/app/models/skip.rb @@ -3,4 +3,6 @@ class Skip < ActiveRecord::Base belongs_to :question belongs_to :prompt has_one :appearance, :as => :answerable + + default_scope :conditions => {:valid_record => true} end diff --git a/app/models/vote.rb b/app/models/vote.rb index 57054fc..bbdda5d 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -18,6 +18,8 @@ class Vote < ActiveRecord::Base named_scope :with_voter_ids, lambda { |*args| {:conditions => {:voter_id=> args.first }} } named_scope :active, :include => :choice, :conditions => { 'choices.active' => true } + default_scope :conditions => {:valid_record => true} + serialize :tracking after_create :update_winner_choice, :update_loser_choice diff --git a/db/migrate/20100719030739_add_valid_flags_to_votes_and_skips.rb b/db/migrate/20100719030739_add_valid_flags_to_votes_and_skips.rb new file mode 100644 index 0000000..c121bf4 --- /dev/null +++ b/db/migrate/20100719030739_add_valid_flags_to_votes_and_skips.rb @@ -0,0 +1,15 @@ +class AddValidFlagsToVotesAndSkips < ActiveRecord::Migration + def self.up + add_column :votes, :valid_record, :boolean, :default => true + add_column :votes, :validity_information, :string + add_column :skips, :valid_record, :boolean, :default => true + add_column :skips, :validity_information, :string + end + + def self.down + remove_column :votes, :valid_record + remove_column :votes, :validity_information + remove_column :skips, :valid_record + remove_column :skips, :validity_information + end +end diff --git a/db/schema.rb b/db/schema.rb index f772103..b933107 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20100716121029) do +ActiveRecord::Schema.define(:version => 20100719030739) do create_table "appearances", :force => true do |t| t.integer "voter_id" @@ -179,6 +179,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do t.datetime "updated_at" t.string "skip_reason" t.string "missing_response_time_exp", :default => "" + t.boolean "valid_record", :default => true + t.string "validity_information" end add_index "skips", ["prompt_id"], :name => "index_skips_on_prompt_id" @@ -224,6 +226,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do t.integer "time_viewed" t.integer "appearance_id" t.string "missing_response_time_exp", :default => "" + t.boolean "valid_record", :default => true + t.string "validity_information" end add_index "votes", ["voter_id"], :name => "index_votes_on_voter_id" -- libgit2 0.21.2