Class: Renalware::Events::TypesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/events/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
# File 'app/controllers/renalware/events/types_controller.rb', line 14

def create
  event_type = Type.new(event_params)
  authorize event_type
  if event_type.save
    redirect_to events_types_path, notice: success_msg_for("event type")
  else
    flash.now[:error] = failed_msg_for("event type")
    render :new, locals: { event_type: event_type }
  end
end

#destroyObject



46
47
48
49
50
# File 'app/controllers/renalware/events/types_controller.rb', line 46

def destroy
  event_type = load_and_authorize_event_type
  event_type.destroy
  redirect_to events_types_path, notice: success_msg_for("event type")
end

#editObject



31
32
33
34
# File 'app/controllers/renalware/events/types_controller.rb', line 31

def edit
  event_type = load_and_authorize_event_type
  render locals: { event_type: event_type }
end

#indexObject



25
26
27
28
29
# File 'app/controllers/renalware/events/types_controller.rb', line 25

def index
  event_types = Type.all
  authorize event_types
  render locals: { event_types: event_types }
end

#newObject



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

def new
  event_type = Type.new
  authorize event_type
  render locals: { event_type: event_type }
end

#updateObject



36
37
38
39
40
41
42
43
44
# File 'app/controllers/renalware/events/types_controller.rb', line 36

def update
  event_type = load_and_authorize_event_type
  if event_type.update(event_params)
    redirect_to events_types_path, notice: success_msg_for("event type")
  else
    flash.now[:error] = failed_msg_for("event type")
    render :edit, locals: { event_type: event_type }
  end
end