Class: Renalware::Accesses::PlansController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/accesses/plans_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/renalware/accesses/plans_controller.rb', line 12

def create
  plan = patient.plans.new(plan_params.merge!(by: current_user))
  authorize plan
  if save_as_current(plan)
    redirect_to patient_accesses_dashboard_path(patient),
                notice: success_msg_for("access plan")
  else
    render_new(plan)
  end
end

#editObject

Because editing a plan means creating a new current version (and terminating the previous current one), we just render the new template using an instance of the current plan.



25
26
27
# File 'app/controllers/renalware/accesses/plans_controller.rb', line 25

def edit
  render_new(find_and_authorize_plan.dup)
end

#newObject



6
7
8
9
10
# File 'app/controllers/renalware/accesses/plans_controller.rb', line 6

def new
  plan = Plan.new
  authorize plan
  render_new(plan)
end

#showObject



29
30
31
32
33
34
# File 'app/controllers/renalware/accesses/plans_controller.rb', line 29

def show
  render locals: {
    patient: patient,
    plan: find_and_authorize_plan
  }
end