Class: Iro::StrategiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/iro/strategies_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/iro/strategies_controller.rb', line 11

def create
  @strategy = Iro::Strategy.new params[:strategy].permit!
  authorize! :create, @strategy

  if @strategy.save
    flash_notice @strategy
  else
    flash_alert @strategy
  end

  redirect_to action: :index
end

#destroyObject



24
25
26
27
28
29
30
# File 'app/controllers/iro/strategies_controller.rb', line 24

def destroy
  @strategy = Iro::Strategy.find params[:id]
  authorize! :destroy, @strategy
  @strategy.delete
  flash_notice "Probably ok"
  redirect_to request.referrer
end

#editObject



32
33
34
35
# File 'app/controllers/iro/strategies_controller.rb', line 32

def edit
  @strategy = Iro::Strategy.find params[:id]
  authorize! :edit, @strategy
end

#indexObject



37
38
39
40
41
# File 'app/controllers/iro/strategies_controller.rb', line 37

def index
  authorize! :index, Iro::Strategy
  @strategies = Iro::Strategy.all
  render '_table'
end

#newObject



6
7
8
9
# File 'app/controllers/iro/strategies_controller.rb', line 6

def new
  @strategy = Iro::Strategy.new
  authorize! :new, @posision
end

#updateObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/iro/strategies_controller.rb', line 43

def update
  @strategy = Iro::Strategy.find params[:id]
  authorize! :update, @strategy

  if @strategy.update params[:strategy].permit!
    flash_notice @strategy
  else
    flash_alert @strategy
  end

  redirect_to action: :index
end