Class: ModelExplorer::ModelsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/model_explorer/models_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
# File 'app/controllers/model_explorer/models_controller.rb', line 5

def index
  @models = ModelExplorer.models.map(&:name).sort
end

#showObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/model_explorer/models_controller.rb', line 9

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