Class: Renalware::Accesses::ProfilesController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/renalware/accesses/profiles_controller.rb', line 19

def create
  profile = patient.profiles.new(profile_params)

  if profile.save
    redirect_to patient_accesses_dashboard_path(patient),
      notice: t(".success", model_name: "Access profile")
  else
    flash.now[:error] = t(".failed", model_name: "Access profile")
    render :new, locals: { patient: patient, profile: profile }
  end
end

#editObject



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

def edit
  profile = patient.profiles.find(params[:id])
  render locals: { patient: patient, profile: profile }
end

#newObject



14
15
16
17
# File 'app/controllers/renalware/accesses/profiles_controller.rb', line 14

def new
  profile = patient.profiles.new(by: current_user)
  render locals: { patient: patient, profile: profile }
end

#showObject



8
9
10
11
12
# File 'app/controllers/renalware/accesses/profiles_controller.rb', line 8

def show
  profile = patient.profiles.find(params[:id])
  presenter = ProfilePresenter.new(profile)
  render locals: { patient: patient, profile: presenter }
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/renalware/accesses/profiles_controller.rb', line 36

def update
  profile = patient.profiles.find(params[:id])

  if profile.update(profile_params)
    redirect_to patient_accesses_dashboard_path(patient),
      notice: t(".success", model_name: "Access profile")
  else
    flash.now[:error] = t(".failed", model_name: "Access profile")
    render :edit, locals: { patient: patient, profile: profile }
  end
end