app/models/decidim/surveys/survey_question.rb in decidim-surveys-0.3.2 vs app/models/decidim/surveys/survey_question.rb in decidim-surveys-0.4.0
- old
+ new
@@ -6,9 +6,11 @@
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