File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 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
3535 end
3636
3737 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
3942 rebuild!
4043 end
41- if changes [ _ct . parent_column_name ] && !@was_new_record
44+ if public_send ( changes_method ) [ _ct . parent_column_name ] && !@was_new_record
4245 # Resetting the ancestral collections addresses
4346 # https://github.com/mceachen/closure_tree/issues/68
4447 ancestor_hierarchies . reload
Original file line number Diff line number Diff line change @@ -10,8 +10,13 @@ module NumericDeterministicOrdering
1010 end
1111
1212 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 )
1520 _ct . reorder_with_parent_id ( was_parent_id )
1621 end
1722 end
You can’t perform that action at this time.
0 commit comments