Sha256: 5d0714fbd6e0ccfb3120f8f73dd7018c813e4b926e5a96f3c23142ceb36b1f15

Contents?: true

Size: 514 Bytes

Versions: 3

Compression:

Stored size: 514 Bytes

Contents

module Rapidfire
  module Questions
    class Checkbox < Rapidfire::Question
      validates :answer_options, :presence => true

      def options
        answer_options.split(/\r?\n/)
      end

      def validate_answer(answer)
        super(answer)

        if rules[:presence] == "1" || answer.answer_text.present?
          answer.answer_text.split(",").each do |value|
            answer.errors.add(:answer_text, :invalid) unless options.include?(value)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
unique_rapidfire-1.0.0 app/models/rapidfire/questions/checkbox.rb
rapidfire-1.2.0 app/models/rapidfire/questions/checkbox.rb
rapidfire-1.0.0 app/models/rapidfire/questions/checkbox.rb