From 94e5a78eda9c9d9ba15598fc494c44eacd4669be Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 13 Oct 2021 13:49:25 +0100 Subject: [PATCH] Add some hated code comments to explain some things --- app/models/case_log.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 1407e9dfd..74b1187cd 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -10,10 +10,15 @@ class CaseLogValidator < ActiveModel::Validator end def validate(record) + # If we've come from the form UI we only want to validate the specific fields + # that have just been submitted. If we're submitting a log via API or Bulk Upload + # we want to validate all data fields. question_to_validate = options[:previous_page] if question_to_validate && respond_to?("validate_#{question_to_validate}") public_send("validate_#{question_to_validate}", record) else + # This assumes that all methods in this class other than this one are + # validations to be run validation_methods = public_methods(false) - [__callee__] validation_methods.each { |meth| public_send(meth, record) } end