class BatchesController
Public Instance Methods
Source
# File app/controllers/batches_controller.rb, line 14 def create batch = authorize Batch.archived.find_or_initialize_by( team: current_team, vaccine: @vaccine, **batch_form_params ) batch.archived_at = nil if batch.archived? @form = BatchForm.new(**batch_form_params, batch:) if expiry_validator.date_params_valid? && @form.save redirect_to vaccines_path, flash: { success: "Batch #{batch.number} added" } else @form.expiry = expiry_validator.date_params_as_struct render :new, status: :unprocessable_content end end
Source
# File app/controllers/batches_controller.rb, line 42 def edit_archive render :archive end
Source
# File app/controllers/batches_controller.rb, line 37 def make_default self.todays_batch = @batch redirect_to vaccines_path end
Source
# File app/controllers/batches_controller.rb, line 9 def new authorize Batch @form = BatchForm.new end
Source
# File app/controllers/batches_controller.rb, line 46 def update_archive @batch.archive! redirect_to vaccines_path, flash: { success: "Batch archived" } end