# Check\_Box Validation Script doesn't work

**URL:** <https://www.ruby-forum.com/t/check-box-validation-script-doesnt-work/192518>\
**Category:** Rails\
**Created:** [August 1, 2010, 2:21am UTC](https://www.ruby-forum.com/t/check-box-validation-script-doesnt-work/192518 "2010-08-01T02:21:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcortes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/97f17d/32.png) [@pcortes](https://www.ruby-forum.com/u/pcortes)\
**Post date:** [August 1, 2010, 2:21am UTC](https://www.ruby-forum.com/t/check-box-validation-script-doesnt-work/192518/1 "2010-08-01T02:21:28Z")

</div>

Hello,

I’m a complete newbie to Rails, and am trying to jump in and add  
something to my application. I’m trying to have users check a checkbox,  
accepting our terms of service, prior to registering. I have validation  
scripts written to ensure that the user first and last name fields  
aren’t left blank (validates\_presence\_of), and also have scripts doing  
password length checks. I cannot for the life of me figure out how to  
make the checkbox validation work.

I have entered the following into my user.rb model :

class User \< ActiveRecord::Base  
validates\_acceptance\_of :eula, :message =\> “must be agreed to”

My other validations are there as well - example:

validates\_presence\_of :first\_name

I have entered the following in the signup.html.erb file :

\<%= check\_box :user, :eula %\>  
By checking this box I am agreeing to  
Meeteor’s Terms of  
Service

I entered this script down near the bottom of the page right next to the  
signup button. My other validation scripts read code from the following  
block :

Personal Information

 \<%form\_for(:user,:url =\> { :controller =\> "users", :action =\> "meetjoe\_signup" },:html =\> { :onsubmit=\>"return true;" }) do |f| %\> 
 \<%= error\_messages\_for :current\_user %\> 
 \<%= f.hidden\_field :login %\> 

I’m not sure I’ve included everything I need to - please let me know if  
anything isn’t clear or if I need to add add’l info. Thank you for your  
help!

| **First Name** | \<%= f.text\_field :first\_name,:class=\>"input-field" %\>\* |

---

<div class="post-metadata">

**Author:** ![pcortes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/97f17d/32.png) [@pcortes](https://www.ruby-forum.com/u/pcortes)\
**Post date:** [August 2, 2010, 4:12pm UTC](https://www.ruby-forum.com/t/check-box-validation-script-doesnt-work/192518/2 "2010-08-02T16:12:26Z")

</div>

On Sat, Jul 31, 2010 at 20:21, Philip C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m trying to have users check a checkbox,  
> accepting our terms of service, prior to registering.

I don’t grok in fullness exactly what’s wrong with your app, but here  
are some resources to look at:

about checkboxes:

> **[ActionView::Helpers::FormHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M002298)**
>
> Form helpers are designed to make working with resources much easier compared to using vanilla HTML.

about validates\_acceptance\_of:  
[http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001396](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001396)

When I’m stuck on a Ruby or Rails problem involving some concept or  
keyword or whatever, I find that googling it with Ruby (e.g., ruby  
checkbox) usually gets me some good help pretty quickly.

-Dave

–  
Specialization is for insects. -RAH | Have Pun, Will Babble! -me  
Programming Blog: [http://codosaur.us](http://codosaur.us) | Work: [http://davearonson.com](http://davearonson.com)  
Leadership Blog: [http://dare2xl.com](http://dare2xl.com) | Play: [http://davearonson.net](http://davearonson.net)

- 
  - 
    - 
      - 
        - WATCH THIS SPACE \* \* \* \* \* | Ruby: [http://mars.groupsite.com](http://mars.groupsite.com)
