# Validates\_confirmation\_of not working

**URL:** <https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822>\
**Category:** Rails\
**Created:** [August 29, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822 "2006-08-29T16:26:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piotr\_Chmolowski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8baadc/32.png) [@Piotr\_Chmolowski](https://www.ruby-forum.com/u/Piotr_Chmolowski)\
**Post date:** [August 29, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822/1 "2006-08-29T16:26:36Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Piotr\_Chmolowski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8baadc/32.png) [@Piotr\_Chmolowski](https://www.ruby-forum.com/u/Piotr_Chmolowski)\
**Post date:** [August 29, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822/2 "2006-08-29T17:07:29Z")

</div>

i’ve been having a lot of problems with that validation.

while running a webserver the error gets added/displayed correctly, but  
in console and unit tests it fails to throw an error. I’m still trying  
to figure out why.

rails 1.1.6

---

<div class="post-metadata">

**Author:** ![Piotr\_Chmolowski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8baadc/32.png) [@Piotr\_Chmolowski](https://www.ruby-forum.com/u/Piotr_Chmolowski)\
**Post date:** [August 29, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822/3 "2006-08-29T17:09:29Z")

</div>

i’m sorry, my error is in validated acceptance of, not confirmation

---

<div class="post-metadata">

**Author:** ![Piotr\_Chmolowski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8baadc/32.png) [@Piotr\_Chmolowski](https://www.ruby-forum.com/u/Piotr_Chmolowski)\
**Post date:** [September 1, 2006, 3:44pm UTC](https://www.ruby-forum.com/t/validates-confirmation-of-not-working/66822/4 "2006-09-01T15:44:28Z")

</div>

I’ve finally found a solution: [http://dev.rubyonrails.org/ticket/1819](http://dev.rubyonrails.org/ticket/1819)

This ticket has been open for a year 😑 If this defect can’t be fixed,  
it should be at least documented in manual.
