]> projects.mako.cc - selectricity-live/blob - app/models/voter.rb
c4700cbbef75d0a82fe8a598c8d454ce5ead4f42
[selectricity-live] / app / models / voter.rb
1 class Voter < ActiveRecord::Base
2   belongs_to :election
3   has_one :vote
4
5   before_create :create_password
6
7   def create_password
8     token_generator = UniqueTokenGenerator.new( 16 )
9     until password and not password.empty? \
10           and Voter.find_all( [ "password = ?", password ]).empty?
11       self.password = token_generator.token
12     end
13   end
14
15 end
16
17
18

Benjamin Mako Hill || Want to submit a patch?