Modified QuickVote table to work by object type and not by the weird
author<mako@atdot.cc> <>
Tue, 7 Aug 2007 23:23:05 +0000 (19:23 -0400)
committer<mako@atdot.cc> <>
Tue, 7 Aug 2007 23:23:05 +0000 (19:23 -0400)
TinyInts so that we can take advantage of the single table inheritence
magic in AR.

app/controllers/site_controller.rb
app/models/election.rb
app/models/quick_vote.rb
db/create.sql

index 776832218c2b9a611e874a50564f3efa42805696..e26a3688997dd1ff67b4b817b44a345ddc8d4cfa 100644 (file)
@@ -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?
index ebd623a6b186d4006d54c2f144557d0003a169fa..cf7bba58a2974f409a2828226d4dd43dc2f023ac 100755 (executable)
@@ -57,7 +57,7 @@ class Election < ActiveRecord::Base
   end
   
   def quickvote?
-    quickvote.to_i == 1
+    type == 'QuickVote'
   end
 
   def active?
index 98379cbb89ffd1497711c5c3ddb5555bb1b9f9ac..8d4e6e82141f8b8c67dab67d0103c170a97f0324 100755 (executable)
@@ -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)
index ff10db3a9357c4b5b57755ef3aa81801af49585e..0a2f4b5b9dc3bca3ae9dd5d60ab57590e310014e 100755 (executable)
@@ -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
+);

Benjamin Mako Hill || Want to submit a patch?