# Implementing password confirmation

**URL:** <https://www.ruby-forum.com/t/implementing-password-confirmation/126375>\
**Category:** Rails\
**Created:** [January 17, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/implementing-password-confirmation/126375 "2008-01-17T20:40:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 17, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/implementing-password-confirmation/126375/1 "2008-01-17T20:40:42Z")

</div>

Hi,

I’m using the latest version of RoR. I’m having a problem with  
passwords and password confirmations. I have a db table and  
corresponding model – customer with a password field (but no password  
confirmation field in the table). Here is the simple customer model  
code:

class Customer \< ActiveRecord::Base  
belongs\_to :subscriber

```
    validates_confirmation_of :password

```

end

Here is part of the view where I’m asking for a password and password  
confirmation:

Password  
\<%= password\_field 'customer', 'password' %\>

Confirm Password  
\<%= password\_field 'password\_confirmation', '' %\>

However, even if the passwords don’t match, the script allows me to  
submit and save the customer. What is missing from the above?

Thanks, - Dave

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 17, 2008, 9:48pm UTC](https://www.ruby-forum.com/t/implementing-password-confirmation/126375/2 "2008-01-17T21:48:32Z")

</div>

> Password  
> \<%= password\_field 'customer', 'password' %\>
> 
> Confirm Password  
> \<%= password\_field 'password\_confirmation', '' %\>

The second password\_field looks bogus, check out the example at:  
[http://www.railsapi.org/validates\_confirmation\_of](http://www.railsapi.org/validates_confirmation_of)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 17, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/implementing-password-confirmation/126375/3 "2008-01-17T23:37:25Z")

</div>

Thanks, but I guess because of my beginner-ness, I’m still confused.  
What should the second password\_field look like in order to not be  
bogus? The link you sent doesn’t have an example of what it should  
look like on the view end.

- Dave

On Jan 17, 2:48 pm, Sven S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
