# Validates\_acceptance\_of with virtual attribute check box

**URL:** <https://www.ruby-forum.com/t/validates-acceptance-of-with-virtual-attribute-check-box/195759>\
**Category:** Rails\
**Created:** [September 29, 2010, 6:00pm UTC](https://www.ruby-forum.com/t/validates-acceptance-of-with-virtual-attribute-check-box/195759 "2010-09-29T18:00:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![khagimoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ee59a6/32.png) [@khagimoto](https://www.ruby-forum.com/u/khagimoto)\
**Post date:** [September 29, 2010, 6:00pm UTC](https://www.ruby-forum.com/t/validates-acceptance-of-with-virtual-attribute-check-box/195759/1 "2010-09-29T18:00:55Z")

</div>

I’ve scoured the web for solution, but I can’t figure out why this is  
not working! I have a terms and conditions check box that user has to  
check in order to register with a site, but it seems to just let user  
register regardless of the check box status.

## Here’s what I have:

## Model: validates\_acceptance\_of :terms\_and\_conditions, :on =\> :create, :message =\> “must be accepted.” attr\_accessible :terms\_and\_conditions

## View(form): \<%= form.check\_box :terms\_and\_conditions %\>

## LOG: (skipping other fields with “…” to save space) Parameters: {“action”=\>“create”, …, “user”=\>{… , “terms\_and\_conditions”=\>“0”,… }}

I am seeing in the log (as shown above) that the  
“terms\_and\_conditions”=\>“0”, when I don’t check the box, and  
“terms\_and\_conditions”=\>“1”, when I check the box.  
But either way, it just goes ahead and creates the record, and no  
warning when I don’t check the box.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![khagimoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ee59a6/32.png) [@khagimoto](https://www.ruby-forum.com/u/khagimoto)\
**Post date:** [September 29, 2010, 7:19pm UTC](https://www.ruby-forum.com/t/validates-acceptance-of-with-virtual-attribute-check-box/195759/2 "2010-09-29T19:19:57Z")

</div>

Never mind… I found out that at “save”, terms\_and\_conditions was not  
being set and that was the problem! Everything works fine now.
