Sha256: 819a1871ab60d2b76afb0719fc07c940b6884b89e6483d95517d859d8c139749

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

# frozen_string_literal: true

module ModelExplorer
  class ModelsController < ApplicationController
    def index
      @models = ModelExplorer.models.map(&:name).sort
    end

    def show
      model_name = params[:id]

      ensure_valid_model_name(model_name)

      render json: ModelSerializer.new(
        model: model_name.constantize,
        macro: params[:macro],
        parent: params[:parent]
      ).to_json
    rescue => error
      render_bad_request(error)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
model_explorer-0.1.0 app/controllers/model_explorer/models_controller.rb