Sha256: 38a450a4bfee563d79c96d9d3f5bb30e3558e5556f3c45ee65a894d883369836
Contents?: true
Size: 1.2 KB
Versions: 5
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Admin class CategoriesController < Admin::AdminController before_action :find_category, only: %i[show edit update destroy] def index @categories = Category.all end def show redirect_to edit_admin_category_url(@category) end def new @category = Category.new end def create @category = Category.create(category_params) if @category.valid? flash[:notice] = t("pages_core.categories_controller.created") redirect_to admin_pages_url(@locale) else render action: :new end end def edit; end def update if @category.update(category_params) flash[:notice] = t("pages_core.categories_controller.updated") redirect_to admin_pages_url(@locale) else render action: :edit end end def destroy @category.destroy flash[:notice] = t("pages_core.categories_controller.deleted") redirect_to admin_pages_url(@locale) end protected def category_params params.require(:category).permit(:name, :slug, :position) end def find_category @category = Category.find(params[:id]) end end end
Version data entries
5 entries across 5 versions & 1 rubygems