diff --git a/app/models/case_log.rb b/app/models/case_log.rb index ac1dd2054..1407e9dfd 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -28,6 +28,8 @@ class CaseLog < ApplicationRecord enum status: { "in progress" => 0, "submitted" => 1 } + AUTOGENERATED_FIELDS = %w[status created_at updated_at id].freeze + def instance_validations validates_with CaseLogValidator, ({ previous_page: @previous_page } || {}) end @@ -37,8 +39,7 @@ class CaseLog < ApplicationRecord end def all_fields_completed? - non_mandatory_fields = %w[status created_at updated_at id] - mandatory_fields = attributes.except(*non_mandatory_fields) + mandatory_fields = attributes.except(*AUTOGENERATED_FIELDS) mandatory_fields.none? { |_key, val| val.nil? } end end