Class: Renalware::HD::CannulationTypesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/hd/cannulation_types_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/renalware/hd/cannulation_types_controller.rb', line 14

def create
  cannulation_type = CannulationType.new(cannulation_type_params)
  authorize cannulation_type

  if cannulation_type.save
    redirect_to hd_cannulation_types_path,
                notice: t(".success", model_name: "cannulation type")
  else
    flash.now[:error] = t(".failed", model_name: "cannulation type")
    render_new(cannulation_type)
  end
end

#destroyObject



49
50
51
52
53
# File 'app/controllers/renalware/hd/cannulation_types_controller.rb', line 49

def destroy
  authorize CannulationType.destroy(params[:id])
  redirect_to hd_cannulation_types_path,
              notice: t(".success", model_name: "cannulation type")
end

#editObject



33
34
35
36
# File 'app/controllers/renalware/hd/cannulation_types_controller.rb', line 33

def edit
  cannulation_type = find_and_authorize_cannulation_type
  render_edit(cannulation_type)
end

#indexObject



27
28
29
30
31
# File 'app/controllers/renalware/hd/cannulation_types_controller.rb', line 27

def index
  cannulation_types = CannulationType.all
  authorize cannulation_types
  render locals: { cannulation_types: cannulation_types }
end

#newObject



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

def new
  cannulation_type = CannulationType.new
  authorize cannulation_type
  render_new(cannulation_type)
end

#updateObject



38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/renalware/hd/cannulation_types_controller.rb', line 38

def update
  cannulation_type = find_and_authorize_cannulation_type
  if cannulation_type.update(cannulation_type_params)
    redirect_to hd_cannulation_types_path,
                notice: t(".success", model_name: "cannulation type")
  else
    flash.now[:error] = t(".failed", model_name: "cannulation type")
    render_edit(cannulation_type)
  end
end