module Adhoq
  class CurrentTablesController < Adhoq::ApplicationController
    before_action :eager_load_models

    def index
      hidden_model_names = Array(Adhoq.config.hidden_model_names)
      hidden_model_names << 'ActiveRecord::SchemaMigration'
      hidden_model_names << 'ApplicationRecord'

      @ar_classes = ActiveRecord::Base.descendants.
        reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) }.
        sort_by(&:name)

      render layout: false
    end

    private

    def eager_load_models
      return unless Rails.env.development?
      [Rails.application, Adhoq::Engine].each(&:eager_load!)
    end
  end
end

module Adhoq
  class CurrentTablesController < Adhoq::ApplicationController
    before_action :eager_load_models

    def index
      hidden_model_names = Array(Adhoq.config.hidden_model_names)
      hidden_model_names << 'ActiveRecord::SchemaMigration'
      hidden_model_names << 'ApplicationRecord'

      @ar_classes = ActiveRecord::Base.descendants.
        reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) || klass.name.nil? }.
        sort_by(&:name)

      render layout: false
    end

    private

    def eager_load_models
      return unless Rails.env.development?
      [Rails.application, Adhoq::Engine].each(&:eager_load!)
    end
  end
end

Fix show table feature error(a case where there is an anonymous class inherited ActiveRecord::Base)
Fix show table feature error(a case where there is an anonymous class inherited ActiveRecord::Base)

If there is an anonymous class inherited ActiveRecord::Base(e.g. SwitchPoint), the show table feature fails.
Because the name is nil in anonymous classes, it fails sorting by table name.
So I excluded anonymous classes.
