From 89ce5f2d365f22284526138432ed17ee90d3b814 Mon Sep 17 00:00:00 2001 From: Marcello Rocha Date: Wed, 23 Oct 2024 18:16:04 +0200 Subject: [PATCH] adds a scope for loading the CF with the root and 2 levels of children --- app/models/custom_field.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index a3902325a1d7..eb74feb97fc9 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -46,6 +46,8 @@ class CustomField < ApplicationRecord dependent: :destroy, inverse_of: "custom_field" + scope :hierarchy_root_and_children, -> { includes(hierarchy_root: { children: :children }) } + acts_as_list scope: [:type] validates :field_format, presence: true