Sha256: 4e67c54e2250f9119c9ceb2efb4c70a4c9a257dd7d23ff02ae4af277763f2b03
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 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 edit; end def create @category = Category.create(category_params) if @category.valid? flash[:notice] = t("pages_core.categories_controller.created") redirect_to admin_pages_url(content_locale) else render action: :new end end def update if @category.update(category_params) flash[:notice] = t("pages_core.categories_controller.updated") redirect_to admin_pages_url(content_locale) else render action: :edit end end def destroy @category.destroy flash[:notice] = t("pages_core.categories_controller.deleted") redirect_to admin_pages_url(content_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