From f3b33f81157ccf002b8c2774b30dc35bd4722610 Mon Sep 17 00:00:00 2001 From: shawndodo Date: Fri, 17 Sep 2021 16:42:18 +0800 Subject: [PATCH] fix: hierarchy model with namespace should inherit from the superclass of basic model (#384) Co-authored-by: xiaoyu --- lib/closure_tree/support.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/closure_tree/support.rb b/lib/closure_tree/support.rb index 75108d79..04cf06b4 100644 --- a/lib/closure_tree/support.rb +++ b/lib/closure_tree/support.rb @@ -33,7 +33,7 @@ def initialize(model_class, options) def hierarchy_class_for_model parent_class = ActiveSupport::VERSION::MAJOR >= 6 ? model_class.module_parent : model_class.parent - hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base)) + hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(model_class.superclass)) use_attr_accessible = use_attr_accessible? include_forbidden_attributes_protection = include_forbidden_attributes_protection? model_class_name = model_class.to_s