Class: Renalware::Clinical::BodyCompositionsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/clinical/body_compositions_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 25

def create
  body_composition = build_body_composition
  if body_composition.save
    redirect_to patient_clinical_profile_path(patient),
    notice: t(".success", model_name: "body composition")
  else
    flash.now[:error] = t(".failed", model_name: "body composition")
    render_new(body_composition)
  end
end

#editObject



36
37
38
39
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 36

def edit
  body_composition = find_body_composition
  render locals: { patient: patient, body_composition: body_composition }
end

#newObject



16
17
18
19
20
21
22
23
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 16

def new
  body_composition = BodyComposition.new(
    patient: patient,
    assessor: current_user,
    assessed_on: Time.zone.today
  )
  render_new(body_composition)
end

#showObject



11
12
13
14
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 11

def show
  body_composition = find_body_composition
  render locals: { patient: patient, body_composition: body_composition }
end

#updateObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 41

def update
  body_composition = find_body_composition
  authorize body_composition
  if body_composition.update(body_composition_params)
    redirect_to patient_clinical_profile_path(patient),
      notice: success_msg_for("body_composition")
  else
    render :edit, locals: { patient: patient, body_composition: body_composition }
  end
end