From eb2eb65219eb8f3c8b57cfbed327c0b2b647f8c7 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Wed, 7 Sep 2016 17:45:50 -0500 Subject: [PATCH] non-summary question edit bug fix --- app/controllers/quiz_controller.rb | 4 +--- app/models/answer.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/quiz_controller.rb b/app/controllers/quiz_controller.rb index ea7e41c..0cb3858 100644 --- a/app/controllers/quiz_controller.rb +++ b/app/controllers/quiz_controller.rb @@ -48,8 +48,8 @@ class QuizController < ApplicationController def answer_params params.require(:answer).permit( :question_id, - :answer_id, :answer, + :answer_id, answer_array: [], answer_hash: [:later, :html, :css, :js, :text, :other, options: []] ) @@ -61,8 +61,6 @@ class QuizController < ApplicationController answer[:submitted] = params.key?(:submit) answer[:answer] = answer_params[:answer_array] unless answer_params[:answer_array].nil? answer[:answer] = answer_params[:answer_hash].to_h unless answer_params[:answer_hash].nil? - answer.delete(:answer_array) - answer.delete(:answer_hash) answer end diff --git a/app/models/answer.rb b/app/models/answer.rb index b1dc993..71a91aa 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -7,4 +7,12 @@ class Answer < ApplicationRecord validates :candidate_id, presence: true validates :question_id, presence: true validates :answer, answer_format: true + + # Throw away attributes + # convenience for form manipulation + def answer_array=(val); end + + def answer_hash=(val); end + + def answer_id=(val); end end