Sha256: badbcfaf6f7c9a170a401bb8de92ec12999c14606a7a6e8442227b77ef04760c

Contents?: true

Size: 577 Bytes

Versions: 5

Compression:

Stored size: 577 Bytes

Contents

module Api::V1
  module SimpleAdmin
    class EntitiesController < BaseController
      before_action :load_models

      def index
        render json: {
          entities_names: ApplicationRecord.descendants.map { |model| model.name }
        }
      end

      def show
        resource_klass = params[:id].capitalize.constantize

        render json: {
          name: resource_klass.name,
          column_names: resource_klass.column_names
        }
      end

      private

        def load_models
          Rails.application.eager_load!
        end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple-admin-1.1.2 app/controllers/api/v1/simple_admin/entities_controller.rb
simple-admin-1.1.1 app/controllers/api/v1/simple_admin/entities_controller.rb
simple-admin-1.0.1 app/controllers/api/v1/simple_admin/entities_controller.rb
simple-admin-1.1.0 app/controllers/api/v1/simple_admin/entities_controller.rb
simple-admin-1.0.0 app/controllers/api/v1/simple_admin/entities_controller.rb