diff --git a/Gemfile b/Gemfile index 4a3b5d48392..bfb998b7bfc 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ manageiq_plugin "manageiq-schema" gem "activerecord-id_regions", "~>0.2.0" gem "activerecord-session_store", "~>1.1" gem "acts_as_tree", "~>2.7" # acts_as_tree needs to be required so that it loads before ancestry -gem "ancestry", "~>2.2.1", :require => false +gem "ancestry", "~>3.0.4", :require => false gem "bcrypt", "~> 3.1.10", :require => false gem "bundler", ">=1.11.1", :require => false gem "color", "~>1.8" diff --git a/lib/patches/ancestry_patch.rb b/lib/patches/ancestry_patch.rb index 147423af394..1dd2e725fbf 100644 --- a/lib/patches/ancestry_patch.rb +++ b/lib/patches/ancestry_patch.rb @@ -24,11 +24,7 @@ module Ancestry module InstanceMethods prepend AncestryInstanceMethodsPatch - ANCESTRY_DELIMITER = '/'.freeze - - def parse_ancestry_column(obj) - obj.to_s.split(ANCESTRY_DELIMITER).map! { |id| cast_primary_key(id) } - end + ANCESTRY_DELIMITER = '/'.freeze unless defined?(ANCESTRY_DELIMITER) def ancestor_ids @_ancestor_ids ||= parse_ancestry_column(read_attribute(ancestry_base_class.ancestry_column)) @@ -60,13 +56,8 @@ def depth end end - STRING_BASED_KEYS = %i[string uuid text].freeze def cast_primary_key(key) - if STRING_BASED_KEYS.include?(primary_key_type) - key - else - key.to_i - end + self.class.primary_key_is_an_integer? ? key.to_i : key end def clear_memoized_instance_variables