Class: Renalware::Transplants::RecipientOperationsController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/renalware/transplants/recipient_operations_controller.rb', line 24

def create
  recipient_operation = RecipientOperation.new(patient: patient)
  recipient_operation.attributes = operation_params

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

#editObject



41
42
43
44
45
46
# File 'app/controllers/renalware/transplants/recipient_operations_controller.rb', line 41

def edit
  render locals: {
    patient: patient,
    recipient_operation: operation
  }
end

#newObject



17
18
19
20
21
22
# File 'app/controllers/renalware/transplants/recipient_operations_controller.rb', line 17

def new
  render locals: {
    patient: patient,
    recipient_operation: RecipientOperation.new
  }
end

#showObject



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

def show
  render locals: {
    patient: patient,
    recipient_operation: operation
  }
end

#updateObject



48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/renalware/transplants/recipient_operations_controller.rb', line 48

def update
  operation.attributes = operation_params

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