1 class QuickVote < Election
2 after_validation :create_candidates
3 validates_uniqueness_of :name
4 attr_accessor :raw_candidates
5 attr_accessor :reviewed
8 if @raw_candidates.length < 2
9 errors.add("You must list at least two candidates.")
12 if name =~ /[^A-Za-z0-9]/
13 errors.add("The name must only include numbers and letters.")
17 def initialize(params={})
19 self.enddate = DateTime.now + 30
24 def candidatelist=(candstring='')
25 @raw_candidates = candstring.split(';').collect {|cand| cand.strip }
29 @raw_candidates.join("; ")
33 read_attribute( :name ).downcase()
45 @raw_candidates.each do |name|
46 candidate = Candidate.new({:name => name})
48 self.candidates << candidate