I try to add an email-validator in my rails app. I created the following file /lib/validators/email_validator.rb
class EmailValidator < Activ
If you place your custom validators in app/validators they will be automatically loaded without needing to alter your config/application.rb file.
Resource: Where should Rails 3 custom validators be stored? (second answer)
Try the modified User model;
class User < ActiveRecord::Base
attr_accessible :email, :password,:name
validates :email, :presence => true, :uniqueness => true
end
This error occures, because rails loads model file before your validation file
Try to require your validation file manually at the start of your model file
require_dependency 'validators/email_validator.rb'