On Sun, Apr 10, 2011 at 11:38 AM, Misha Ognev <[email protected]> wrote:

> Bryan, I mean: why rails don't need confirmation of password?
>
>
http://edgeguides.rubyonrails.org/active_record_validations_callbacks.html#validates_confirmation_of

You are already asking in your model for it to validate the presence of the
password, it's length between 6-40 characters, and that it matches the
password in the password_confirmation field. It's all on this one line.

 validates :password, :presence => true, :length => {:within => 6..40},
:confirmation => true

It only runs that validation if password_confirmation is not nil. Since you
aren't supplying a :password_confirmation in your create statement it is
treated as nil therefore no check is run. You need to require the that the
user give you password_confirmation. Add the following right after the above
code line and that should fix your issue.

validates :password_confirmation, :presence => true


B.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to