Hi,
I’ve got a really weird problem with validates_confirmation_of. I’ve
been developing my app for quite some time and everything went fine so
far. After (more or less) a month of coding I got back to check my user
registration code and noticed that validates_confirmation_of doesn’t
work any more. The code looks 100% correct to me:
class User < ActiveRecord::Base
attr_accessible :login, :password, :email
validates_presence_of :login, :password, :email
validates_uniqueness_of :login, :email
validates_length_of :login, :within => 4..40
validates_length_of :password, :within => 5..40
validates_format_of :login, :with => /^[a-zA-z0-9_\-]{4,30}$/
validates_format_of :email, :with => /^[_a-z0 -9-]+(\.[_a
-z0-9-]+)@[a-z0-9-]+(.[a-z0 -9-]+)(.[a-z]{2,4})$/i
validates_confirmation_of :email, :if => Proc.new {|u| u.email.size >
0}
validates_confirmation_of :password :if => Proc.new {|u|
u.password.size > 0}
end
Other validation methods work fine. Have you seen a similar problem
before? What can be wrong with it?
(I’m running Rails 1.1.2 on my local machine)