@@ -6,7 +6,7 @@ module Model
6
6
7
7
included do
8
8
9
- belongs_to :parent , nil , *_ct . belongs_to_with_optional_option (
9
+ belongs_to :parent , nil , ** _ct . belongs_to_with_optional_option (
10
10
class_name : _ct . model_class . to_s ,
11
11
foreign_key : _ct . parent_column_name ,
12
12
inverse_of : :children ,
@@ -15,11 +15,11 @@ module Model
15
15
16
16
order_by_generations = -> { Arel . sql ( "#{ _ct . quoted_hierarchy_table_name } .generations ASC" ) }
17
17
18
- has_many :children , *_ct . has_many_with_order_option (
18
+ has_many :children , *_ct . has_many_order_with_option , ** {
19
19
class_name : _ct . model_class . to_s ,
20
20
foreign_key : _ct . parent_column_name ,
21
21
dependent : _ct . options [ :dependent ] ,
22
- inverse_of : :parent ) do
22
+ inverse_of : :parent } do
23
23
# We have to redefine hash_tree because the activerecord relation is already scoped to parent_id.
24
24
def hash_tree ( options = { } )
25
25
# we want limit_depth + 1 because we don't do self_and_descendants.
@@ -28,25 +28,21 @@ def hash_tree(options = {})
28
28
end
29
29
end
30
30
31
- has_many :ancestor_hierarchies , *_ct . has_many_without_order_option (
31
+ has_many :ancestor_hierarchies , *_ct . has_many_order_without_option ( order_by_generations ) ,
32
32
class_name : _ct . hierarchy_class_name ,
33
- foreign_key : 'descendant_id' ,
34
- order : order_by_generations )
33
+ foreign_key : 'descendant_id'
35
34
36
- has_many :self_and_ancestors , *_ct . has_many_without_order_option (
35
+ has_many :self_and_ancestors , *_ct . has_many_order_without_option ( order_by_generations ) ,
37
36
through : :ancestor_hierarchies ,
38
- source : :ancestor ,
39
- order : order_by_generations )
37
+ source : :ancestor
40
38
41
- has_many :descendant_hierarchies , *_ct . has_many_without_order_option (
39
+ has_many :descendant_hierarchies , *_ct . has_many_order_without_option ( order_by_generations ) ,
42
40
class_name : _ct . hierarchy_class_name ,
43
- foreign_key : 'ancestor_id' ,
44
- order : order_by_generations )
41
+ foreign_key : 'ancestor_id'
45
42
46
- has_many :self_and_descendants , *_ct . has_many_with_order_option (
43
+ has_many :self_and_descendants , *_ct . has_many_order_with_option ( order_by_generations ) ,
47
44
through : :descendant_hierarchies ,
48
- source : :descendant ,
49
- order : order_by_generations )
45
+ source : :descendant
50
46
end
51
47
52
48
# Delegate to the Support instance on the class:
0 commit comments