Class: Renalware::HD::PreferenceSetsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/hd/preference_sets_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#editObject



10
11
12
13
# File 'app/controllers/renalware/hd/preference_sets_controller.rb', line 10

def edit
  preference_set = PreferenceSet.for_patient(patient).first_or_initialize
  render locals: { patient: patient, preference_set: preference_set }
end

#updateObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/renalware/hd/preference_sets_controller.rb', line 15

def update
  preference_set = PreferenceSet.for_patient(patient).first_or_initialize

  if preference_set.update(preference_set_params)
    redirect_to patient_hd_dashboard_path(patient),
                notice: t(".success", model_name: "HD preferences")
  else
    flash.now[:error] = t(".failed", model_name: "HD preferences")
    render :edit, locals: { patient: patient, preference_set: preference_set }
  end
end