Hi Railers,
I’m past considering myself a noob in Rails land - I think what I’m up
against
here is more of a bug or an anomaly that I’m unaware of (or that has
changed
in a recent version).
I had a fully working validates_confirmation_of :email_address field in
my app
- was one of the first things I set up, extremely simple, been working
for a
long time.
Then one day I notice that it’s not working any more - the validator
basically
doesn’t care if you fill in the email_address field but not
email_address_confirmation, and it certainly doesn’t care if they don’t
match.
I’ve tried looking at the examples again, and my code follows them to
the
letter (with the exception that my field name is different). I’ve
checked the
logs and the appropriate parameters are being sent through.
In desperation, I even tried validates_presence_of
:email_address_confirmation
to ensure that it’s filled in - that works to enforce the field in the
form,
yet the confirmation check still doesn’t seem to take place.
It was my belief (and this certainly worked fine exactly like this for a
long
time) that if I had…
validates_presence_of :email_address
validates_confirmation_of :email_address
… that would take care of enforcing that both fields are filled in and
match
each other.
I haven’t changed anything on this code, yet it’s stopped doing the
confirmation validation.
Could anyone else confirm this is/isn’t the case? I’m running Rails
1.0.0 and
Ruby 1.8.4.
This thread appears to be discussing a similar problem, but it’s not
quite the
same: http://thread.gmane.org/gmane.comp.lang.ruby.rails/25445
I’ve also searched the Rails Trac bugs database, and can’t find anything
about
this problem.
I’m enforcing the format of the email address using…
validates_format_of :email_address,
:with => /^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/,
:message => “is not valid”,
:if => Proc.new {|model| !model.email_address.blank?}
…which combined with my other validations surely should (and did for a
long
time) take care of all possible scenarios with the email addresses.
Meaning:
- Neither field present.
- Email address present, confirmation not.
- Confirmation present, email address not.
- Both present, don’t match.
- Both present, match, but format is not an email address.
- Both present, match, format is an email address.
So something is seriously amiss here, and I don’t know what it is, but
this
used to work fine, and it’s just stopped working.
Anyone else? Thanks for your help!
Cheers,
~Dave
–
Dave S.
Rent-A-Monkey Website Development