]> projects.mako.cc - selectricity/blobdiff - app/models/full_voter.rb
Refined the CSS and fixed some of the more recent issues.
[selectricity] / app / models / full_voter.rb
index 04071a0f398555adaf1bd10b4b0a6cf25ecc243b..b82667c3f926f6d82f61e3844010744cc2466fdf 100644 (file)
@@ -5,8 +5,16 @@ class FullVoter < Voter
   def create_password
     token_generator = UniqueTokenGenerator.new( 16 )
     until password and not password.empty? \
-          and Voter.find_all( [ "password = ?", password ]).empty?
+          and Voter.find(:all, :conditions => [ "password = ?", password ]).empty?
       self.password = token_generator.token
     end
   end
+  
+  protected
+  def validate
+    # E-mail regex, moderate complexity
+    # Stolen from http://www.regular-expressions.info/email.html
+    errors.add(:email, "is not valid") unless email  =~
+                  /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
+  end
 end

Benjamin Mako Hill || Want to submit a patch?