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
26 self.candidates.each do |candidate|
35 if self.candidates.length <= 1
36 reasons << "You must have at least two candidates."
39 if self.voters.length <= 1
40 reasons << "You must have at least two voters."
64 shortdesc = description.split(/\n/)[0]
68 longdesc = description.split(/\n/)[1..-1].join("")
69 longdesc.length > 0 ? longdesc : nil