Rails: validates_acceptance_of is acting crazy

What's wrong with this image?

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 DB I have organizations.terms_of_service.

Every time I receive "Terms of Service must be accepted"

If i use

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

      

The check is not yet complete.

If I turn off: accept => true this check seems to pass, but when I look at postgres it says false. Shouldn't Rails be throwing this stuff?

Why can't I say:

Model:

validates_acceptance_of :terms_of_service, :accept => true

      

View:

check_box blah, blah, options, true

      

and see in my database true?

Any ideas on what's going on?

File Info: DB is Postgres and Rails 2.1 is running

+2


a source to share


2 answers


Remove the declaration accessor

for the TOS attribute.



+4


a source


Try



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

      

0


a source







All Articles