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
25 def candidatelist=(candstring='')
26 @raw_candidates = candstring.split(';').collect {|cand| cand.strip }
30 @raw_candidates.join("; ")
34 read_attribute( :name ).downcase()
42 @raw_candidates.each do |name|
43 candidate = Candidate.new({:name => name})
45 self.candidates << candidate