Sha256: 96a7a4bb5e4255145738b50a4e95f8bf81213235aae774bccf24f37a2a9fe719

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 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) }.
        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

1 entries across 1 versions & 1 rubygems

Version Path
adhoq-0.2.0 app/controllers/adhoq/current_tables_controller.rb