Sha256: a708823ec8c00e73e02c81fef4dbe41afe39cd5b0e07a214cfe1f9ff32437718
Contents?: true
Size: 666 Bytes
Versions: 48
Compression:
Stored size: 666 Bytes
Contents
# frozen_string_literal: true module Decidim module Surveys # The data store for a SurveyQuestion in the Decidim::Surveys component. class SurveyQuestion < Surveys::ApplicationRecord TYPES = %w(short_answer long_answer single_option multiple_option).freeze belongs_to :survey, class_name: "Survey", foreign_key: "decidim_survey_id" validates :question_type, inclusion: { in: TYPES } # Rectify can't handle a hash when using the from_model method so # the answer options must be converted to struct. def answer_options self[:answer_options].map { |option| OpenStruct.new(option) } end end end end
Version data entries
48 entries across 48 versions & 2 rubygems