Class: Renalware::Modalities::ModalitiesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/modalities/modalities_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/renalware/modalities/modalities_controller.rb', line 23

def create
  result = change_patient_modality
  if result.success?
    handle_valid_modality
  else
    flash.now[:error] = t(".failed", model_name: "modality")
    render :new, locals: { patient: patient, modality: result.object }
  end
end

#indexObject



15
16
17
18
19
20
21
# File 'app/controllers/renalware/modalities/modalities_controller.rb', line 15

def index
  modalities = patient
                 .modalities
                 .includes([:description, :created_by])
                 .ordered
  render locals: { patient: patient, modalities: modalities }
end

#newObject



10
11
12
13
# File 'app/controllers/renalware/modalities/modalities_controller.rb', line 10

def new
  modality = Modality.new(patient: patient)
  render locals: { patient: patient, modality: modality }
end