Unknown validator: 'email_format'
Rails.root: /home/saran/work_space/rails_apps/test_app Application Trace | Framework Trace | Full Trace
app/models/user.rb:2 app/controllers/user_controller.rb:5:in `create'
my user model file as below:-
class User < ActiveRecord::Base validates :email, :presence => true, :uniqueness => true, :email_format => true
end
my lib class introduced as below:-
:~/work_space/rails_apps/test_app/lib$ cat email_format_validator.rb
class EmailFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i
object.errors[attribute] << (options[:message] || "is not formatted properly")
end
end
end
Am using Rails version 3.0
Thanks in advance.