model - Rails 3 - validation of checkboxes -
I have a form 2 checkbox and I have tried to find a way, how to validate it - I want to know, if A user clicked on one of the two checkboxes ...
I tried to do this with Anybody help me, please, how? You can use custom valid work for it. To make this work, you must have 2 checkboxes in your view files. validates_presence_of , but unfortunately, without success ...
Valid: custom_checkbox_validation def custom_checkbox_validation errors.add (: base, "Please check a checkbox.") Unless chkbox1 || Chkbox2 end
& lt;% = form.check_box: chkbox1% & gt; & Lt;% = form.check_box: chkbox2% & gt;
Comments
Post a Comment