Thursday, February 25, 2010

validates_confirmation_of


You should use this helper when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with “_confirmation” appended.

class Person < class="symbol"> :email end In your view template you could use something like <%= text_field :person, :email %> <%= text_field :person, :email_confirmation %> This check is performed only if email_confirmation is not nil. To require confirmation, make sure to add a presence check for the confirmation attribute class Person < class="symbol"> :email validates_presence_of :email_confirmation end The default error message for validates_confirmation_of is “doesn’t match confirmation”.

0 comments:

Post a Comment

post answers

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com