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 = Time.now + 30.days
25 def candidatelist=(candlist)
26 @raw_candidates = candlist
30 read_attribute( :name ).downcase()
38 @raw_candidates.each do |name|
39 candidate = Candidate.new({:name => name})
41 self.candidates << candidate