module ActiveRecord::Inheritance::ClassMethods

def find_sti_class(type_name)

def find_sti_class(type_name)
  type_name = base_class.type_for_attribute(inheritance_column).cast(type_name)
  subclass = sti_class_for(type_name)
  unless subclass == self || descendants.include?(subclass)
    raise SubclassNotFound, "Invalid single-table inheritance type: #{subclass.name} is not a subclass of #{name}"
  end
  subclass
end