Actions
Bug #24069
openOrganization is not a subclass of Taxonomy
Status:
New
Priority:
Normal
Assignee:
-
Category:
Rails
Target version:
-
Description
Foreman with Katello is sometimes returning the error "Invalid single-table inheritance type: Organization is not a subclass of Taxonomy." It now happens almost every other hammer command for me on a dev environment. It has to do with Rails' DescendantTracker losing descendants of Taxonomy. I don't know what it means yet, but probably something with rails autoloading and Katello's taxonomy extensions.
From: /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/inheritance.rb @ line 203 ActiveRecord::Inheritance::ClassMethods#find_sti_class: 187: def find_sti_class(type_name) 188: type_name = base_class.type_for_attribute(inheritance_column).cast(type_name) 189: subclass = begin 190: if store_full_sti_class 191: ActiveSupport::Dependencies.constantize(type_name) 192: else 193: compute_type(type_name) 194: end 195: rescue NameError 196: raise SubclassNotFound, 197: "The single-table inheritance mechanism failed to locate the subclass: '#{type_name}'. " \ 198: "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " \ 199: "Please rename this column if you didn't intend it to be used for storing the inheritance class " \ 200: "or overwrite #{name}.inheritance_column to use another column for that information." 201: end 202: unless subclass == self || descendants.include?(subclass) => 203: require 'pry-remote'; binding.remote_pry 204: raise SubclassNotFound, "Invalid single-table inheritance type: #{subclass.name} is not a subclass of #{name}" 205: end 206: subclass 207: end [1] pry(Taxonomy)> self => Taxonomy(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime) [2] pry(Taxonomy)> desendants NameError: undefined local variable or method `desendants' for #<Class:0x0000000a4afce0> Did you mean? descendants from /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/dynamic_matchers.rb:22:in `method_missing' [3] pry(Taxonomy)> descendants => [] [4] pry(Taxonomy)> method(:descendants).source_location => ["/home/vagrant/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/descendants_tracker.rb", 56] [5] pry(Taxonomy)> ActiveSupport::DescendantsTracker.descendants ArgumentError: wrong number of arguments (given 0, expected 1) from /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/descendants_tracker.rb:12:in `descendants' [6] pry(Taxonomy)> ActiveSupport::DescendantsTracker.descendants(self) => [] [7] pry(Taxonomy)> Taxonomy.descendants => [Location(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime), Organization(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime)]
Actions