basic_app/app/controllers/admin/p_price_cats_controller.rb
Nicolas Bally fd027c16c1 initial
2020-04-21 21:53:16 +02:00

66 lines
961 B
Ruby

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