I know that the RoR can do the validation in the models. But I want to confirm the user's password in the views. I means, it show two textfield for user to type password twice to ensure the user type the password correct, but in the database I only store one value. How can I handle it in the RoR?
1 Answer
In your model do:
validates_confirmation_of :password
In your view do:
<%= form.password_field :password %>
<%= form.password_field :password_confirmation %>
This is using the built in rails confirmation validation. It's will add the virtual accessor for you.
2 Comments
DNB5brims
Wow, that's so sample to do so. Er.... ...One more thing, how can I check all the validation in RoR, is there any document out there? Thx in advance. Xmas.
nas
You can check api docs online here api.rubyonrails.org/classes/ActiveRecord/Validations/…