Class: Iro::StrategiesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #schwab_sync

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/iro/strategies_controller.rb', line 6

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



19
20
21
22
23
24
25
# File 'app/controllers/iro/strategies_controller.rb', line 19

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

#editObject



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

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

#indexObject



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

def index
  authorize! :index, Iro::Strategy
  @strategies = Iro::Strategy.all

  # render '_table'
end

#newObject



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

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

#showObject



44
45
46
47
# File 'app/controllers/iro/strategies_controller.rb', line 44

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

#updateObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/iro/strategies_controller.rb', line 51

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