I have the following form for the model below it:
= simple_form_for @mem, :url => signup_path, :html => {:id => 'signup_form'}, :method => :post do |f|
= f.input :interest, label: "I would like to learn more about:", collection: [ ['Interest 1', 'Interest 1' ], ['Interest 2', 'Interest 2']], :as => :check_boxes
%br
= f.input :full_name, :as => :string, required: true
= f.input :email, :as => :string, required: true
= f.input :telephone, :as => :string, required: true
= f.submit "Submit"
Model:
class User
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :full_name, :email, :telephone, :interest
validates :interest, presence: { :message => "Please select your interest."}
I am able to successfully validate the other 3 fields in the form however I am having trouble validating the presence of the checkbox field :interest
. I want to ensure that the user selects either one or both of the options. Thanks for your help