Sha256: 7aed04cb4d4f21f88675b505925b8143a00d51f9878eb628ea40829a428568e6
Contents?: true
Size: 1.38 KB
Versions: 15
Compression:
Stored size: 1.38 KB
Contents
require_dependency "renalware/transplants/base_controller" module Renalware module Transplants class DonorWorkupsController < BaseController before_action :load_patient def show workup = DonorWorkup.for_patient(patient).first_or_initialize if workup.new_record? redirect_to edit_patient_transplants_donor_workup_path(patient) else render locals: { patient: patient, workup: workup } end end def edit workup = DonorWorkup.for_patient(patient).first_or_initialize render locals: { patient: patient, workup: workup } end def update workup = DonorWorkup.for_patient(patient).first_or_initialize if workup.update_attributes(workup_params) redirect_to patient_transplants_donor_workup_path(patient), notice: t(".success", model_name: "donor work up") else flash.now[:error] = t(".failed", model_name: "donor work up") render :edit, locals: { patient: patient, workup: workup } end end private def workup_params params .require(:transplants_donor_workup) .permit .merge(document: document_attributes) end def document_attributes params .require(:transplants_donor_workup) .fetch(:document, nil).try(:permit!) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems