From fd159879204be83a55f61b9f1ccbb8074b2a3de9 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Wed, 4 Dec 2024 15:10:33 +0100 Subject: [PATCH] Fix validation for host_resources nil Ignore validation in case host_resources are not present. --- .../concerns/foreman_resource_quota/host_managed_extensions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb b/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb index 3d9793f..a52a78b 100644 --- a/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +++ b/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb @@ -19,7 +19,7 @@ module HostManagedExtensions # A host shall always have a .host_resources attribute before_validation :build_host_resources, unless: -> { host_resources.present? } - after_save :save_host_resources, if: -> { host_resources.changed? } + after_save :save_host_resources, if: -> { host_resources&.changed? } end def verify_resource_quota