mardi 7 mars 2017

Rails form_for checkbox validation without record in database

I'm trying to create an User register form that has to accept a set of terms and condition, but I don't know how to use the value of the checkbox to verify if it was clicked(server side).

I've tried to use this http://ift.tt/1MXyh8L, but so far I haven't achieved anything.

I have validates :terms_of_service, acceptance: { accept: '1' } in my User.rb and in my form <%= f.check_box :terms_of_service,:value =>'0',:class =>"hidden", :id =>"t_and_c" %>, but I can submit the form without clicking on it. What am I doing wrong? If I have to post anything else to make the question easier to understand let me know.

Aucun commentaire:

Enregistrer un commentaire