Skip to content

Commit 27a2992

Browse files
committed
Call Module#module_parent instead of deprecated #parent
Sourced from ClosureTree#354
1 parent 1bc10c8 commit 27a2992

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/closure_tree/support.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def initialize(model_class, options)
3232
end
3333

3434
def hierarchy_class_for_model
35-
hierarchy_class = model_class.parent.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base))
35+
parent_class = ActiveSupport::VERSION::MAJOR >= 6 ? model_class.module_parent : model_class.parent
36+
hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base))
3637
use_attr_accessible = use_attr_accessible?
3738
include_forbidden_attributes_protection = include_forbidden_attributes_protection?
3839
hierarchy_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1

0 commit comments

Comments
 (0)