views:

91

answers:

2

Whats wrong with this picture?

Model:

validates_acceptance_of :terms_of_service, :on => :create, :accept => true, :allow_nil => false
accessor :terms_of_service

View:

<%= check_box :organisation,'terms_of_service', {:style => "margin-left:0px"}, 1, 0 %>

And in the DB I have organisations.terms_of_service.

Every time I get "Terms of service must be accepted"

If I use

<%= check_box :organisation,'terms_of_service', {:style => "margin-left:0px"}, true, false %>

The validation still fails.

If I turn off :accept => true, It the validation seems to pass but when I look at postgres it says false. Isn't Rails supposed to be casting this stuff?

Why don't I seem to be able to say:

Model:

validates_acceptance_of :terms_of_service, :accept => true

view:

check_box blah, blah, options, true

and see a true in my database?

Any ideas on whats going on?

Pertinent info: DB is Postgres and running Rails 2.1

A: 

Try

<%= check_box :organisation,'terms_of_service', {:style => "margin-left:0px"}, '1', '0' %>
Salil
A: 

Remove the accessor declaration for the TOS attribute.

Fred
Thanks Fred. You rock.
Mike Williamson