Validates_acceptance_of weirdness

On my registration form I have a checkbox for a waiver. In the model I
have the statement:

validates_acceptance_of :waiver, :on => :create, :message => “must be
accepted”

In the view:

<%= check_box_tag(“waiver”) %>
<%= error_message_on “user”, “waiver”, "Waiver "%>

For some reason validate is accepting everything when the checkbox is
NOT checked. When it is not checked the value is nil – when checked it
is “1”.

What am I missing here? There are no other validation statements with
:waiver in them. I have put manual code in the “Create” method of the
“user” controller to verify that valid() is accepting blank checkbox
that has value nil.

Why do the easy things get so complex? LOL

Mike K. wrote:

On my registration form I have a checkbox for a waiver. In the model I
have the statement:

validates_acceptance_of :waiver, :on => :create, :message => “must be
accepted”

In the view:

<%= check_box_tag(“waiver”) %>
<%= error_message_on “user”, “waiver”, "Waiver "%>

For some reason validate is accepting everything when the checkbox is
NOT checked. When it is not checked the value is nil – when checked it
is “1”.

What am I missing here? There are no other validation statements with
:waiver in them. I have put manual code in the “Create” method of the
“user” controller to verify that valid() is accepting blank checkbox
that has value nil.

Why do the easy things get so complex? LOL

you need “check_box(‘user’, ‘waiver’)”

You actually have to assign the value of that checkbox to the model for
the validation. This way when you do a “@some_model =
Model.new(params[:user])” the :waiver attribute gets assigned to it.

Most likely that’s your problem.