Sha256: 2a7256956b97252428d70f4ea3a8df4546a07919af2b7971f67ff8e55e8324f5

Contents?: true

Size: 688 Bytes

Versions: 6

Compression:

Stored size: 688 Bytes

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adhoq-1.0.2 app/controllers/adhoq/current_tables_controller.rb
adhoq-1.0.1 app/controllers/adhoq/current_tables_controller.rb
adhoq-1.0.0 app/controllers/adhoq/current_tables_controller.rb
adhoq-0.5.0 app/controllers/adhoq/current_tables_controller.rb
adhoq-0.4.0 app/controllers/adhoq/current_tables_controller.rb
adhoq-0.3.0 app/controllers/adhoq/current_tables_controller.rb