Class: Renalware::Transplants::RegistrationStatusesController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/renalware/transplants/registration_statuses_controller.rb', line 17

def create
  status = registration.add_status!(status_params)

  if status.valid?
    redirect_to patient_transplants_recipient_dashboard_path(patient),
      notice: t(".success", model_name: "registration status")
  else
    flash.now[:error] = t(".failed", model_name: "registration status")
    render :new, locals: { patient: patient, status: status }
  end
end

#destroyObject



48
49
50
51
52
53
54
# File 'app/controllers/renalware/transplants/registration_statuses_controller.rb', line 48

def destroy
  status = registration.statuses.find(params[:id])
  registration.delete_status!(status)

  redirect_to patient_transplants_recipient_dashboard_path(patient),
    notice: t(".success", model_name: "registration status")
end

#editObject



29
30
31
32
33
34
35
# File 'app/controllers/renalware/transplants/registration_statuses_controller.rb', line 29

def edit
  status = registration.statuses.find(params[:id])
  render locals: {
    patient: patient,
    status: status
  }
end

#newObject



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

def new
  render locals: {
    patient: patient,
    status: registration.statuses.build
  }
end

#updateObject



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

def update
  status = update_status
  if status.valid?
    redirect_to patient_transplants_recipient_dashboard_path(patient),
      notice: t(".success", model_name: "registration status")
  else
    flash.now[:error] = t(".failed", model_name: "registration status")
    render :edit, locals: { patient: patient, status: status }
  end
end