From 69a90c7f0f805860778210035ac67c2c9ee82903 Mon Sep 17 00:00:00 2001 From: Derek Leadbetter Date: Tue, 27 Sep 2022 14:59:49 -0400 Subject: [PATCH] UDF #19 - Updating fieldable concern to treat user_defined attribute as JSON --- app/models/concerns/user_defined_fields/fieldable.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/concerns/user_defined_fields/fieldable.rb b/app/models/concerns/user_defined_fields/fieldable.rb index f95279c..8e1e58e 100644 --- a/app/models/concerns/user_defined_fields/fieldable.rb +++ b/app/models/concerns/user_defined_fields/fieldable.rb @@ -43,8 +43,7 @@ def validate_user_defined_fields next unless field.required? # Parse the user defined field and extract the value - json = JSON.parse(self.user_defined || '{}') - value = json[field.column_name] + value = self.user_defined[field.column_name] if self.user_defined.present? # Add an error if the value is "empty" next unless value.nil? ||