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

Benjamin Mako Hill || Want to submit a patch?