1 class Election < ActiveRecord::Base
6 validates_presence_of :name, :description
11 read_attribute( :startdate ) || Time.now
15 date = read_attribute( :enddate ) || Time.now + 14
27 self.voters.each do |voter|
34 self.candidates.each do |candidate|
43 if self.candidates.length <= 1
44 reasons << "You must have at least two candidates."
47 if self.voters.length <= 1
48 reasons << "You must have at least two voters."
60 self.class == 'QuickVote'
72 shortdesc = description.split(/\n/)[0]
76 longdesc = description.split(/\n/)[1..-1].join("")
77 longdesc.length > 0 ? longdesc : nil