File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ def _ct_before_save
35
35
end
36
36
37
37
def _ct_after_save
38
- if changes [ _ct . parent_column_name ] || @was_new_record
38
+ as_5_1 = ActiveSupport . version >= Gem ::Version . new ( '5.1.0' )
39
+ changes_method = as_5_1 ? :saved_changes : :changes
40
+
41
+ if public_send ( changes_method ) [ _ct . parent_column_name ] || @was_new_record
39
42
rebuild!
40
43
end
41
- if changes [ _ct . parent_column_name ] && !@was_new_record
44
+ if public_send ( changes_method ) [ _ct . parent_column_name ] && !@was_new_record
42
45
# Resetting the ancestral collections addresses
43
46
# https://github.com/mceachen/closure_tree/issues/68
44
47
ancestor_hierarchies . reload
Original file line number Diff line number Diff line change @@ -10,8 +10,13 @@ module NumericDeterministicOrdering
10
10
end
11
11
12
12
def _ct_reorder_prior_siblings_if_parent_changed
13
- if attribute_changed? ( _ct . parent_column_name ) && !@was_new_record
14
- was_parent_id = attribute_was ( _ct . parent_column_name )
13
+ as_5_1 = ActiveSupport . version >= Gem ::Version . new ( '5.1.0' )
14
+ change_method = as_5_1 ? :saved_change_to_attribute? : :attribute_changed?
15
+
16
+ if public_send ( change_method , _ct . parent_column_name ) && !@was_new_record
17
+ attribute_method = as_5_1 ? :attribute_before_last_save : :attribute_was
18
+
19
+ was_parent_id = public_send ( attribute_method , _ct . parent_column_name )
15
20
_ct . reorder_with_parent_id ( was_parent_id )
16
21
end
17
22
end
You can’t perform that action at this time.
0 commit comments