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 validates_presence_of , but unfortunately, without success ... Anybody help me, please, how? You can use custom valid work for it. Valid: custom_checkbox_validation def custom_checkbox_validation errors.add (: base, "Please check a checkbox.") Unless chkbox1 || Chkbox2 end To make this work, you must have 2 checkboxes in your view files. & lt;% = form.check_box: chkbox1% & gt; & Lt;% = form.check_box: chkbox2% & gt;