Ruby on Rails validator plugin for password fields
I’m working on a site that allows users to create password protected accounts (Pretty much like every other website around) and I needed a way to check that the password field and confirm password field were the same.
I saw this as an opportunity to play with plug ins :)
You can download the validates_equality_of plug here.
Instructions for use:
- Untar the file into the plugins directory of your rails application
- You now have access to the validates_equality_of method
Easy!
The method is called in the following manner (assuming you have fields called password and confirm_password)
validates_equality_of :password, :with => :confirm_password
You can override the message in the usual way by supplying a :message attribute.
Hope someone find it useful.