1 class Election < ActiveRecord::Base
6 validates_presence_of :name, :description
11 read_attribute( :startdate ) || DateTime.now
15 read_attribute( :enddate ) || DateTime.now + 14
19 self.candidates.each do |candidate|
28 if self.candidates.length <= 1
29 reasons << "You must have at least two candidates."
32 if self.voters.length <= 1
33 reasons << "You must have at least two voters."
48 shortdesc = description.split(/\n/)[0]
52 longdesc = description.split(/\n/)[1..-1].join("")
53 longdesc.length > 0 ? longdesc : nil