Sha256: ec1013db9953e856860b3084edcfa43e11ae05b14235d995632c959b68867f43

Contents?: true

Size: 737 Bytes

Versions: 5

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

class Comfy::Admin::Cms::CategoriesController < Comfy::Admin::Cms::BaseController

  before_action :load_category, only: %i[edit update destroy]
  before_action :authorize

  def edit
    render
  end

  def create
    @category = @site.categories.create!(category_params)
  rescue ActiveRecord::RecordInvalid
    head :ok
  end

  def update
    @category.update_attributes!(category_params)
  rescue ActiveRecord::RecordInvalid
    head :ok
  end

  def destroy
    @category.destroy
  end

protected

  def load_category
    @category = @site.categories.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    head :ok
  end

  def category_params
    params.fetch(:category, {}).permit!
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.17 app/controllers/comfy/admin/cms/categories_controller.rb
comfortable_mexican_sofa-2.0.16 app/controllers/comfy/admin/cms/categories_controller.rb
comfortable_mexican_sofa-2.0.15 app/controllers/comfy/admin/cms/categories_controller.rb
comfortable_mexican_sofa-2.0.14 app/controllers/comfy/admin/cms/categories_controller.rb
comfortable_mexican_sofa-2.0.13 app/controllers/comfy/admin/cms/categories_controller.rb