From 77430b3c3f13d2077b3ccb1237ce796e7155cd6a Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 6 Jun 2023 17:38:35 +0100 Subject: [PATCH] refactor: simplify wip --- app/models/log.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/log.rb b/app/models/log.rb index 845a22693..caa7a19f0 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -106,7 +106,8 @@ class Log < ApplicationRecord errors.each do |error| next if setup_ids.include?(error.attribute.to_s) - if form.questions.find { |q| q.id == error.attribute.to_s }.type == "checkbox" + question = form.questions.find { |q| q.id == error.attribute.to_s } + if question.type == "checkbox" question.answer_options.each_key { |attribute| public_send("#{attribute}=", nil) } else public_send("#{error.attribute}=", nil)