Class: Renalware::Transplants::DonorOperationsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/transplants/donor_operations_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/renalware/transplants/donor_operations_controller.rb', line 19

def create
  operation = DonorOperation.new(patient: patient)
  operation.attributes = operation_params

  if operation.save
    redirect_to patient_transplants_donor_dashboard_path(patient),
                notice: t(".success", model_name: "donor operation")
  else
    flash.now[:error] = t(".failed", model_name: "donor operation")
    render :new, locals: { operation: operation, patient: patient }
  end
end

#editObject



32
33
34
35
# File 'app/controllers/renalware/transplants/donor_operations_controller.rb', line 32

def edit
  operation = DonorOperation.for_patient(patient).find(params[:id])
  render locals: { operation: operation, patient: patient }
end

#newObject



15
16
17
# File 'app/controllers/renalware/transplants/donor_operations_controller.rb', line 15

def new
  render locals: { operation: DonorOperation.new, patient: patient }
end

#showObject



10
11
12
13
# File 'app/controllers/renalware/transplants/donor_operations_controller.rb', line 10

def show
  operation = DonorOperation.for_patient(patient).find(params[:id])
  render locals: { operation: operation, patient: patient }
end

#updateObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/renalware/transplants/donor_operations_controller.rb', line 37

def update
  operation = DonorOperation.for_patient(patient).find(params[:id])
  operation.attributes = operation_params

  if operation.save
    redirect_to patient_transplants_donor_dashboard_path(patient),
                notice: t(".success", model_name: "donor operation")
  else
    flash.now[:error] = t(".failed", model_name: "donor operation")
    render :edit, locals: { operation: operation, patient: patient }
  end
end