Class: PrintJobsController

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

Overview

Print new barcode labels Pretty simple wrapper for print job, and incredibly un-opinionated, simply passes the parameters straight through to the print job.

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/print_jobs_controller.rb', line 7

def create
  @print_job = PrintJob.new(print_job_params)
  @print_job.printer = find_printer_from_name

  if @print_job.execute
    flash.notice = "Your label(s) have been sent to #{print_job_params[:printer_name]}"
  else
    flash.alert = truncate_flash(@print_job.errors.full_messages.uniq)
  end
  redirect_back(fallback_location: :root)
end