Class: GelsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Instance Method Details

#findObject


17
18
# File 'app/controllers/gels_controller.rb', line 17

def find
end

#indexObject


11
12
13
14
15
# File 'app/controllers/gels_controller.rb', line 11

def index
  # TODO: if a plate has a working dilution plate and it has a gel dilution plate, display:
  @gel_plates = GelDilutionPlate.page(params[:page]).order(id: :desc)
  @plates     = @gel_plates.map(&:stock_plate).compact
end

#lookupObject


20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/gels_controller.rb', line 20

def lookup
  @plate = Plate.find_from_barcode([params[:barcode], "#{Plate.default_prefix}#{params[:barcode]}"])
  unless @plate
    flash[:error] = 'plate not found'
    render action: :find
    return
  end

  render action: :show
end

#showObject


31
32
33
# File 'app/controllers/gels_controller.rb', line 31

def show
  @plate = Plate.find(params[:id])
end

#updateObject


35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/gels_controller.rb', line 35

def update
  ActiveRecord::Base.transaction do
    params[:wells].keys.each do |well_id|
      well = Well.find(well_id)
      well.well_attribute.update!(gel_pass: params[:wells][well_id][:qc_state])
      well.events.create_gel_qc!(params[:wells][well_id][:qc_state], current_user)
    end
    Plate.find(params[:id]).events.create_gel_qc!('', current_user)
  end
  flash[:notice] = 'Gel results for plate updated'
  redirect_to action: :index
end