Class: CompletionKit::Api::V1::CalibrationsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- CompletionKit::Api::V1::CalibrationsController
- Defined in:
- app/controllers/completion_kit/api/v1/calibrations_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/completion_kit/api/v1/calibrations_controller.rb', line 20 def create calibration = scope_calibrations.find_or_initialize_by(created_by: created_by_param) calibration.assign_attributes( run: @run, response: @response, metric: @metric, metric_version: MetricVersion.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 |
#destroy ⇒ Object
37 38 39 40 |
# File 'app/controllers/completion_kit/api/v1/calibrations_controller.rb', line 37 def destroy @calibration.destroy! head :no_content end |
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/completion_kit/api/v1/calibrations_controller.rb', line 9 def index scope = Calibration.all scope = scope.where(run_id: params[:run_id]) if params[:run_id].present? scope = scope.where(response_id: params[:response_id]) if params[:response_id].present? scope = scope.where(metric_id: params[:metric_id]) if params[:metric_id].present? scope = scope.where(metric_version_id: params[:metric_version_id]) if params[:metric_version_id].present? scope = scope.where(created_by: params[:created_by]) if params[:created_by].present? scope = scope.where(verdict: params[:verdict]) if params[:verdict].present? render json: paginate(scope.order(:created_at)) end |