Class: Renalware::Patients::AlertsController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject

POST js



16
17
18
19
20
21
22
23
24
# File 'app/controllers/renalware/patients/alerts_controller.rb', line 16

def create
  alert = Alert.new(alert_params.merge!(by: user, patient: patient))
  authorize alert
  if alert.save
    render locals: { patient: patient, alert: alert }
  else
    render_form(alert, status: 422)
  end
end

#destroyObject

POST js Idempotent



28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/renalware/patients/alerts_controller.rb', line 28

def destroy
  alert = find_alert
  if alert.present?
    authorize alert
    alert.destroy
    render locals: { alert: alert }
  else
    skip_authorization
    head :ok
  end
end

#newObject

GET html



9
10
11
12
13
# File 'app/controllers/renalware/patients/alerts_controller.rb', line 9

def new
  alert = Alert.new
  authorize alert
  render_form(alert)
end