Class: Api::V2::QcAssaysController

Inherits:
JSONAPI::ResourceController
  • Object
show all
Defined in:
app/controllers/api/v2/qc_assays_controller.rb

Overview

QcAssaysController

Instance Method Summary collapse

Instance Method Details

#createObject


7
8
9
10
11
12
13
14
15
# File 'app/controllers/api/v2/qc_assays_controller.rb', line 7

def create
  @qc_result_factory = QcResultFactory.new(qc_assay_params)
  if @qc_result_factory.valid?
    @qc_result_factory.save
    render json: JSONAPI::ResourceSerializer.new(QcAssayResource).serialize_to_hash(QcAssayResource.new(@qc_result_factory.qc_assay, nil)), status: :created
  else
    render json: { errors: @qc_result_factory.errors }, status: :unprocessable_entity
  end
end

#qc_assay_paramsObject


17
18
19
# File 'app/controllers/api/v2/qc_assays_controller.rb', line 17

def qc_assay_params
  params.require(:data).require(:attributes).permit(:lot_number, qc_results: %i[barcode uuid well_location key value units cv assay_type assay_version])
end