Thursday, February 25, 2010

validates_acceptance_of


Validates that a checkbox on the user interface was checked when a form was submitted. This is typically used when the user needs to agree to your application’s terms of service, confirm reading some text, or any similar concept. This validation is very specific to web applications and this ‘acceptance’ does not need to be recorded anywhere in your database (if you don’t have a field for it, the helper will just create a virtual attribute). class Person < ActiveRecord::Base validates_acceptance_of :terms_of_service end

The default error message for validates_acceptance_of is “must be accepted”.

validates_acceptance_of can receive an :accept option, which determines the value that will be considered acceptance. It defaults to “1”, but you can change this. class Person < ActiveRecord::Base validates_acceptance_of :terms_of_service, :accept => 'yes' end

0 comments:

Post a Comment

post answers

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com