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?
+6
A:
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.
jonnii
2009-12-26 12:05:24
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.
Ted Wong
2009-12-26 12:10:01
You can check api docs online here http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html
nas
2009-12-26 12:14:35