How can I validate the confirmation of the password? So that the user get an error if the passwords don’t match together. Same as the function “validates_presence_of” gives errors out whether the field is empty.
Sadly doesn’t work this code for me.
<div class="field_left">
<%= f.label :password, "Password" %><br />
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Password retry<span>*</span>".html_safe %><br />
<%= f.password_field :password_confirmation %>
</div>
class User < ActiveRecord::Base
validates_confirmation_of :password
attr_accessible :password, :password_confirmation
attr_accessor :password
end
Can someone help me?
Thank you very much in advance!
The problem was that I implemented the method new so:
Instead of:
then it works with