开发者

Rails: validates_acceptance_of acting crazy

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


Remove the accessor declaration for the TOS attribute.


Try

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜