Class: Iro::StocksController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/iro/stocks_controller.rb', line 21

def create
  @stock = Iro::Stock.new(stock_params)
  authorize! :create, @stock

  if @stock.save
    flash_notice @stock
  else
    flash_alert @stock
  end
  redirect_to action: :index
end

#destroyObject



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

def destroy
  @stock.destroy
  redirect_to stocks_url, notice: 'Stock was successfully destroyed.'
end

#editObject



18
19
# File 'app/controllers/iro/stocks_controller.rb', line 18

def edit
end

#indexObject



5
6
7
8
# File 'app/controllers/iro/stocks_controller.rb', line 5

def index
  @stocks = Iro::Stock.all
  authorize! :index, Iro::Stock
end

#newObject



13
14
15
16
# File 'app/controllers/iro/stocks_controller.rb', line 13

def new
  @stock = Iro::Stock.new
  authorize! :new, @stock
end

#showObject



10
11
# File 'app/controllers/iro/stocks_controller.rb', line 10

def show
end

#updateObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/iro/stocks_controller.rb', line 33

def update
  @stock = Iro::Stock.find params[:id]
  authorize! :update, @stock
  if @stock.update(stock_params)
    flash_notice @stock
  else
    flash_alert @stock
  end
  redirect_to request.referrer
end