intra_app/app/controllers/admin/p_customer_cats_controller.rb
Nicolas Bally 761e075bb6 initial
2018-11-08 21:47:30 +01:00

77 lines
1.1 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::PCustomerCatsController < ApplicationController
layout "admin"
before_filter :auth_admin
before_filter :admin_space
def admin_space
@admin_space = "clients"
end
def index
@p_customer_cats = PCustomerCat.order(:name).all
end
def show
@p_customer_cat = PCustomerCat.find(params[:id])
end
def new
@p_customer_cat = PCustomerCat.new
end
def edit
@p_customer_cat = PCustomerCat.find(params[:id])
end
def create
@p_customer_cat = PCustomerCat.new(params.require(:p_customer_cat).permit!)
if @p_customer_cat.save
@p_customer_cats = PCustomerCat.order(:name).all
else
render action: "new"
end
end
def update
@p_customer_cat = PCustomerCat.find(params[:id])
if @p_customer_cat.update_attributes(params.require(:p_customer_cat).permit!)
@p_customer_cats = PCustomerCat.order(:name).all
else
render action: "edit"
end
end
def destroy
@p_customer_cat = PCustomerCat.find(params[:id])
@p_customer_cat.destroy
end
end