lockaz_app/app/controllers/admin/stock_lines_controller.rb
Nicolas Bally f20fe482c6 initial
2020-04-06 10:38:07 +02:00

66 lines
949 B
Ruby

# -*- encoding : utf-8 -*-
class Admin::StockLinesController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@stock_lines = StockLine.order(:name).all
end
def show
@stock_line = StockLine.find(params[:id])
end
def new
@stock_line = StockLine.new
end
def edit
@stock_line = StockLine.find(params[:id])
end
def create
@stock_line = StockLine.new(params.require(:stock_line).permit!)
if @stock_line.save
else
render action: "new"
end
end
def update
@stock_line = StockLine.find(params[:id])
if @stock_line.update_attributes(params.require(:stock_line).permit!)
else
render action: "edit"
end
end
def destroy
@stock_line = StockLine.find(params[:id])
@stock_line.destroy
end
end