Class: Renalware::Clinical::BodyCompositionsController

Inherits:
BaseController show all
Includes:
Renalware::Concerns::Pageable
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



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 31

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



42
43
44
45
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 42

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

#indexObject



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

def index
  body_compositions = BodyComposition.for_patient(patient).ordered.page(page).per(per_page)
  render locals: { patient: patient, body_compositions: body_compositions }
end

#newObject



22
23
24
25
26
27
28
29
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 22

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

#showObject



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

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

#updateObject



47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/renalware/clinical/body_compositions_controller.rb', line 47

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