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/sorecop_cats_controller.rb
2021-09-23 18:19:47 +02:00

77 lines
1.3 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::SorecopCatsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@sorecop_cats = SorecopCat.all
@sorecop_cats = sort_by_sorting(@sorecop_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
@sorecop_cats = @sorecop_cats.page(page).per(per_page)
}
end
end
def show
@sorecop_cat = SorecopCat.find(params[:id])
end
def new
@sorecop_cat = SorecopCat.new
end
def edit
@sorecop_cat = SorecopCat.find(params[:id])
end
def create
@sorecop_cat = SorecopCat.new(params.require(:sorecop_cat).permit!)
if @sorecop_cat.save
else
render action: "new"
end
end
def update
@sorecop_cat = SorecopCat.find(params[:id])
if @sorecop_cat.update_attributes(params.require(:sorecop_cat).permit!)
else
render action: "edit"
end
end
def destroy
@sorecop_cat = SorecopCat.find(params[:id])
@sorecop_cat.destroy
end
end