Well that’s what I was thinking…

Issue:

validates_confirmation_of doesn’t seem to be working.

Setup:

I have a table in my DB called “people” with fields called “yourname” and “yourpassword”

Resolution:

If you are having issues getting ‘_confirmation’ to work, look in your  scaffold structure to be certain the ‘_confirmation’ field is included everywhere it is needed:

in your ‘view’:

.
.
<div class="field">
<%= form.label :password %>
<%= form.password_field :yourpassword %>
<%= form.label :confirm_password %>
<%= form.password_field :yourpassword_confirmation %>
</div>
.
.

In your ‘model’:

.
.
validates_confirmation_of :yourpassword
.
.

In your ‘controller’:

.
.
private
.
.
# Never trust parameters from the scary internet, only allow the white list through.
def people_params
params.require(:people).permit(:yourname, :yourpassword, :yourpassword_confirmation)
end
.
.

This is the one that got me… if 'yourpassword_confirmation' is not included as a ‘white listed’ field ( ‘.permit’ ) it will be ignored COMPLETELY!… adding stuff manually requires a follow through of all locations within the scaffold structure.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>