Class: CompletionKit::Api::V1::CalibrationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/completion_kit/api/v1/calibrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/completion_kit/api/v1/calibrations_controller.rb', line 12

def create
  calibration = scope_calibrations.find_or_initialize_by(created_by: created_by_param)
  calibration.assign_attributes(
    run: @run,
    response: @response,
    metric: @metric,
    judge_version: JudgeVersion.ensure_current_for(@metric),
    **calibration_params
  )

  if calibration.save
    render json: calibration, status: calibration.previously_new_record? ? :created : :ok
  else
    render json: { errors: calibration.errors }, status: :unprocessable_entity
  end
end

#indexObject



8
9
10
# File 'app/controllers/completion_kit/api/v1/calibrations_controller.rb', line 8

def index
  render json: scope_calibrations
end