Check_Box Validation Script doesn't work

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" %>*

On Sat, Jul 31, 2010 at 20:21, Philip C. [email protected]
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:
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M002298

about validates_acceptance_of:
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 | Work: http://davearonson.com
Leadership Blog: http://dare2xl.com | Play: http://davearonson.net

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs