Sha256: 63fe93b16aabd2baa4cc56618061d2a01fdd4625ffa950e905027095481e5b94

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 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| 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adhoq-0.1.2 app/controllers/adhoq/current_tables_controller.rb
adhoq-0.1.1 app/controllers/adhoq/current_tables_controller.rb