From ee5274b3522d972a05b39a068970b80e08d64b9a Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Sun, 7 Mar 2021 07:32:52 +0200 Subject: [PATCH] Fix JS error when saving survey_question --- app/models/survey_question.rb | 4 ++-- app/views/admin/survey_questions/_form.html.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/survey_question.rb b/app/models/survey_question.rb index e1cb0427..2936977a 100644 --- a/app/models/survey_question.rb +++ b/app/models/survey_question.rb @@ -11,8 +11,8 @@ class SurveyQuestion < ActiveRecord::Base validates :title, presence: true validates :possible_answers, :max_choices, :min_choices, presence: true, if: :choice? - validates :min_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true - validates :max_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true + validates :min_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true, if: :choice? + validates :max_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true, if: :choice? validate :max_choices_greater_than_min diff --git a/app/views/admin/survey_questions/_form.html.haml b/app/views/admin/survey_questions/_form.html.haml index 2538c17c..eb861944 100644 --- a/app/views/admin/survey_questions/_form.html.haml +++ b/app/views/admin/survey_questions/_form.html.haml @@ -15,7 +15,7 @@ .row .col-md-12 - = f.input :title + = f.input :title, input_html: { autofocus: true } = f.input :mandatory .survey-possible-answers{ class: @survey_question.choice? ? '' : 'hidden' } = f.input :possible_answers, hint: 'Comma separated', input_html: { rows: 3 }