Sha256: ca4f094dc9bed9c00d3d340435071ebc3e8876408d752991b7a3bf709f539a57

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

class Iro::StocksController < Iro::ApplicationController
  before_action :set_stock, only: [:show, :edit, :update, :destroy]

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

  def show
  end

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

  def edit
  end

  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

  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

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

  ##
  ## private
  ##
  private

  def set_stock
    @stock = Iro::Stock.find(params[:id])
  end

  def stock_params
    params.require(:stock).permit!
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
iron_warbler-2.0.7.22 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.21 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.20 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.19 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.18 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.17 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.16 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.15 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.14 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.13 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.12 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.11 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.10 app/controllers/iro/stocks_controller.rb
iron_warbler-2.0.7.9 app/controllers/iro/stocks_controller.rb