Class: Renalware::Problems::NotesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/problems/notes_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
30
# File 'app/controllers/renalware/problems/notes_controller.rb', line 19

def create
  note = problem.notes.create(notes_params)
  authorize(note)
  if note.save
    render_index
  else
    render_form(
      note,
      url: patient_problem_notes_path(patient, problem)
    )
  end
end

#destroyObject



52
53
54
55
56
# File 'app/controllers/renalware/problems/notes_controller.rb', line 52

def destroy
  authorize note
  note.destroy!
  render_index
end

#editObject



32
33
34
35
36
37
38
# File 'app/controllers/renalware/problems/notes_controller.rb', line 32

def edit
  authorize note
  render_form(
    note,
    url: patient_problem_note_path(patient, problem, note)
  )
end

#indexObject



6
7
8
# File 'app/controllers/renalware/problems/notes_controller.rb', line 6

def index
  render_index
end

#newObject



10
11
12
13
14
15
16
17
# File 'app/controllers/renalware/problems/notes_controller.rb', line 10

def new
  note = problem.notes.new
  authorize(note)
  render_form(
    note,
    url: patient_problem_notes_path(patient, problem)
  )
end

#updateObject



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/renalware/problems/notes_controller.rb', line 40

def update
  authorize note
  if note.update_by(current_user, notes_params)
    render_index
  else
    render_form(
      note,
      url: patient_problem_notes_path(patient, problem)
    )
  end
end