Commit d621467b
Changed files (2)
app
models
app/models/email_validator.rb
@@ -0,0 +1,8 @@
+class EmailValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
+ record.errors[attribute] << (options[:message] || "is not an email")
+ end
+ end
+end
+
app/models/user.rb
@@ -1,13 +1,5 @@
require 'bcrypt'
-class EmailValidator < ActiveModel::EachValidator
- def validate_each(record, attribute, value)
- unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
- record.errors[attribute] << (options[:message] || "is not an email")
- end
- end
-end
-
class User < ActiveRecord::Base
include BCrypt
before_save :ensure_authentication_token