This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/controllers/admin/p_commercial_object_cats_controller.rb
2021-08-23 10:26:02 +02:00

77 lines
1.6 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::PCommercialObjectCatsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@p_commercial_object_cats = PCommercialObjectCat.all
@p_commercial_object_cats = sort_by_sorting(@p_commercial_object_cats, "id DESC")
respond_to do |format|
format.html{
params[:search][:per_page] = params[:search][:per_page] || 100
per_page = params[:search][:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@p_commercial_object_cats = @p_commercial_object_cats.page(page).per(per_page)
}
end
end
def show
@p_commercial_object_cat = PCommercialObjectCat.find(params[:id])
end
def new
@p_commercial_object_cat = PCommercialObjectCat.new
end
def edit
@p_commercial_object_cat = PCommercialObjectCat.find(params[:id])
end
def create
@p_commercial_object_cat = PCommercialObjectCat.new(params.require(:p_commercial_object_cat).permit!)
if @p_commercial_object_cat.save
else
render action: "new"
end
end
def update
@p_commercial_object_cat = PCommercialObjectCat.find(params[:id])
if @p_commercial_object_cat.update_attributes(params.require(:p_commercial_object_cat).permit!)
else
render action: "edit"
end
end
def destroy
@p_commercial_object_cat = PCommercialObjectCat.find(params[:id])
@p_commercial_object_cat.destroy
end
end