From a5d83c1090c30fa3f99c42ea7e8aacd53e8f39a4 Mon Sep 17 00:00:00 2001 From: Markus Graf Date: Mon, 4 Aug 2014 12:58:11 +0200 Subject: [PATCH] makeup --- app/models/helena/sub_question.rb | 5 ++++- app/views/helena/admin/questions/_sub_questions.html.haml | 4 ++-- app/views/helena/admin/versions/_form.html.haml | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/helena/sub_question.rb b/app/models/helena/sub_question.rb index 5060aff..0d0ded1 100644 --- a/app/models/helena/sub_question.rb +++ b/app/models/helena/sub_question.rb @@ -18,7 +18,10 @@ class SubQuestion def uniqueness_of_code question_code_occurences = question.question_group.version.question_code_occurences - errors.add(:code, :taken, value: code) if question_code_occurences[code] > 1 + + return true if question_code_occurences[code] <= 1 + + errors.add(:code, :taken, value: code) end end end diff --git a/app/views/helena/admin/questions/_sub_questions.html.haml b/app/views/helena/admin/questions/_sub_questions.html.haml index 7ae1abb..95f3b4c 100644 --- a/app/views/helena/admin/questions/_sub_questions.html.haml +++ b/app/views/helena/admin/questions/_sub_questions.html.haml @@ -28,5 +28,5 @@ = sub_question.input :value, label: false, as: :hidden, value: 1 %td.delete - unless sub_question.object.new_record? - = sub_question.input :_destroy, as: :boolean, - label: Helena::SubQuestion.human_attribute_name(:_destroy) + = sub_question.input :_destroy, as: :boolean, + label: Helena::SubQuestion.human_attribute_name(:_destroy) diff --git a/app/views/helena/admin/versions/_form.html.haml b/app/views/helena/admin/versions/_form.html.haml index d9bad2b..c4759d8 100644 --- a/app/views/helena/admin/versions/_form.html.haml +++ b/app/views/helena/admin/versions/_form.html.haml @@ -1,4 +1,5 @@ = simple_form_for [:admin, @survey, @version] do |f| = f.input :notes = f.input :session_report, as: :text, input_html: { cols: 60, rows: 10 }, hint: t('.session_report_hint') + = f.submit t('shared.save'), class: 'btn btn-success'