From: Date: Tue, 7 Aug 2007 23:23:05 +0000 (-0400) Subject: Modified QuickVote table to work by object type and not by the weird X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/afa6b59aed60497d059af87c049c0b4f1a6c8b6c Modified QuickVote table to work by object type and not by the weird TinyInts so that we can take advantage of the single table inheritence magic in AR. --- diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 7768322..e26a368 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -3,7 +3,7 @@ class SiteController < ApplicationController model :user, :election, :account def index - @quickvotes = QuickVote.find(:all, ["quickvote = 1"]).sort {|a,b| b.enddate <=> a.enddate}[0..1] + @quickvotes = QuickVote.find(:all).sort {|a,b| b.enddate <=> a.enddate}[0..1] # if the person claims they are logged in if logged_in? diff --git a/app/models/election.rb b/app/models/election.rb index ebd623a..cf7bba5 100755 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -57,7 +57,7 @@ class Election < ActiveRecord::Base end def quickvote? - quickvote.to_i == 1 + type == 'QuickVote' end def active? diff --git a/app/models/quick_vote.rb b/app/models/quick_vote.rb index 98379cb..8d4e6e8 100755 --- a/app/models/quick_vote.rb +++ b/app/models/quick_vote.rb @@ -19,7 +19,6 @@ class QuickVote < Election self.enddate = Time.now + 30.days self.active = 1 self.anonymous = 1 - self.quickvote = 1 end def candidatelist=(candlist) diff --git a/db/create.sql b/db/create.sql index ff10db3..0a2f4b5 100755 --- a/db/create.sql +++ b/db/create.sql @@ -11,7 +11,7 @@ create table elections ( enddate datetime NOT NULL, active tinyint NOT NULL DEFAULT 0, user_id int NULL, - quickvote tinyint NOT NULL DEFAULT 0, + `type` varchar(100) NOT NULL, primary key (id), constraint fk_user_election foreign key (user_id) references users(id) ); @@ -124,4 +124,4 @@ create table users ( remember_token text, remember_token_expires_at datetime, primary key(id) -); \ No newline at end of file +);