Class: Renalware::Patients::WorryController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/patients/worry_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject

idempotent



9
10
11
12
13
14
15
16
# File 'app/controllers/renalware/patients/worry_controller.rb', line 9

def create
  worry = Worry.find_or_create_by!(patient: patient) do |wor|
    wor.by = user
  end
  update_worry_notes_if_supplied(worry)
  redirect_back(fallback_location: patient_path(patient),
                notice: t(".success", patient: patient))
end

#destroyObject

idempotent



19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/renalware/patients/worry_controller.rb', line 19

def destroy
  if (worry = patient.worry)
    authorize worry
    worry.destroy!
  else
    skip_authorization
  end
  redirect_back(fallback_location: patient_path(patient),
                notice: t(".success", patient: patient))
end