Sha256: c2ac221977887cef766a5762084ccc681f3536c8f9c56333ccff456a988b4b94

Contents?: true

Size: 485 Bytes

Versions: 2

Compression:

Stored size: 485 Bytes

Contents

module Rapidfire
  class Answer < ApplicationRecord
    belongs_to :question
    belongs_to :attempt, inverse_of: :answers

    validates :question, :attempt, presence: true
    validate  :verify_answer_text

    if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2"
      has_one_attached :file
      has_many_attached :files
    end

    private

    def verify_answer_text
      return false unless question.present?
      question.validate_answer(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapidfire-8.0.0 app/models/rapidfire/answer.rb
rapidfire-5.0.0 app/models/rapidfire/answer.rb