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