Sha256: 014d574d6e5e06865942f88c0f90813a32cfabb871b19bb5209aaf0e7d0d465c

Contents?: true

Size: 741 Bytes

Versions: 13

Compression:

Stored size: 741 Bytes

Contents

module Fe
  module AnswerConcern
    extend ActiveSupport::Concern
    include ActionView::Helpers::TextHelper

    begin
      included do

        belongs_to :answer_sheet, optional: true
        belongs_to :question, optional: true, class_name: "Element", foreign_key: "question_id"

        before_save :set_value_from_filename
      end
    rescue ActiveSupport::Concern::MultipleIncludedBlocks
    end

    def set(value)
      self.value = value
    end

    def to_s
      self.value
    end

    def set_value_from_filename
      self.value = self.attachment_file_name if self[:attachment_file_name].present?
    end

    module ClassMethods
      def table_name
        "#{Fe.table_name_prefix}answers"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fe-2.1.5 app/models/concerns/fe/answer_concern.rb
fe-2.1.4 app/models/concerns/fe/answer_concern.rb
fe-2.1.3 app/models/concerns/fe/answer_concern.rb
fe-2.1.2 app/models/concerns/fe/answer_concern.rb
fe-2.1.1 app/models/concerns/fe/answer_concern.rb
fe-2.0.8 app/models/concerns/fe/answer_concern.rb
fe-2.0.6 app/models/concerns/fe/answer_concern.rb
fe-2.0.5 app/models/concerns/fe/answer_concern.rb
fe-2.0.4 app/models/concerns/fe/answer_concern.rb
fe-2.0.3 app/models/concerns/fe/answer_concern.rb
fe-2.0.2 app/models/concerns/fe/answer_concern.rb
fe-2.0.1 app/models/concerns/fe/answer_concern.rb
fe-2.0.0 app/models/concerns/fe/answer_concern.rb