Class: Renalware::PD::BagTypesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/pd/bag_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/pd/bag_types_controller.rb', line 14

def create
  bag_type = BagType.new(bag_type_params)
  authorize bag_type

  if bag_type.save
    redirect_to pd_bag_types_path,
      notice: t(".success", model_name: "bag type")
  else
    flash.now[:error] = t(".failed", model_name: "bag type")
    render :new, locals: { bag_type: bag_type }
  end
end

#destroyObject



48
49
50
51
52
# File 'app/controllers/renalware/pd/bag_types_controller.rb', line 48

def destroy
  bag_type = load_and_authorize_bag_type
  bag_type.destroy!
  redirect_to pd_bag_types_path, notice: t(".success", model_name: "bag type")
end

#editObject



33
34
35
# File 'app/controllers/renalware/pd/bag_types_controller.rb', line 33

def edit
  render locals: { bag_type: load_and_authorize_bag_type }
end

#indexObject



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

def index
  bag_types = BagType.ordered
  authorize bag_types
  render locals: { bag_types: bag_types }
end

#newObject



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

def new
  bag_type = BagType.new
  authorize bag_type
  render locals: { bag_type: bag_type }
end

#updateObject



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

def update
  bag_type = load_and_authorize_bag_type
  if bag_type.update(bag_type_params)
    redirect_to pd_bag_types_path,
      notice: t(".success", model_name: "bag type")
  else
    flash.now[:error] = t(".failed", model_name: "bag type")
    render :edit, locals: { bag_type: bag_type }
  end
end