Sha256: b8d060db19757d5ead30cbd23dd0d0472435039976b5fc7a102873e95901aa54

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

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

    begin
      included do

        belongs_to :answer_sheet
        belongs_to :question, :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

2 entries across 2 versions & 1 rubygems

Version Path
fe-1.0.0 app/models/fe/concerns/answer_concern.rb
fe-0.0.4 app/models/fe/concerns/answer_concern.rb