Variety of improvements and additions:
[selectricity-live] / app / models / election.rb
1 class Election < ActiveRecord::Base
2   has_many :candidates
3   has_many :voters
4   has_many :votes
5   validates_presence_of :name, :description
6
7   require 'date'
8
9   def startdate
10     read_attribute( :startdate ) || DateTime.now
11   end
12
13   def enddate
14     read_attribute( :enddate ) || DateTime.now + 14
15   end
16
17   def destroy
18     self.candidates.each do |candidate|
19       candidate.destroy
20     end
21     super
22   end
23   
24 end

Benjamin Mako Hill || Want to submit a patch?