← back to the blog
fousa blog
26
FEB
Contact form validations with AR helpers
This is how you validate a contact form with the validation helpers used in ActiveRecord.
This piece of code enables you to validate:
- presence of the name and content
- format of the website (example: http://www.fousa.be)
- format of the email address (example: test@fousa.be)
- value of the snow field (snow must be "cold")
I also implemented the new_record? method so you can use the form helper and it redirects to the correct controller with a post request!
Here is the code on Gist:
Send me some feedback!