Lets say you have a form with the following checkboxes.
<%= f.check_box :checkbox1 %> <%= f.check_box :checkbox2 %> <%= f.check_box :checkbox3 %>
Now to make sure atleast one checkbox is checked, add the following code to your model.
validate :atleast_one_is_checked
def atleast_one_is_checked
errors.add(:base, "Select atleast one output format type") unless checkbox1 || checkbox2 || checkbox3
end
i trying this whit an array
but i can use unless checkbox[1] or checkbox.count in the validator… :/