Sha256: e47f98f406e7e2e0947f41686f515988c3856511dbc86528c37c4841b74c6214

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

module KktShoppe
  class ProductCategoriesController < KktShoppe::ApplicationController

    before_filter { @active_nav = :product_categories }
    before_filter { params[:id] && @product_category = KktShoppe::ProductCategory.find(params[:id]) }

    def index
      @product_categories_without_parent = KktShoppe::ProductCategory.without_parent.ordered
    end

    def new
      @product_category = KktShoppe::ProductCategory.new
    end

    def create
      @product_category = KktShoppe::ProductCategory.new(safe_params)
      if @product_category.save
        redirect_to :product_categories, :flash => { :notice => t('kkt_shoppe.product_category.create_notice') }
      else
        render :action => "new"
      end
    end

    def edit
    end

    def update
      if @product_category.update(safe_params)
        redirect_to [:edit, @product_category], :flash => { :notice => t('kkt_shoppe.product_category.update_notice') }
      else
        render :action => "edit"
      end
    end

    def destroy
      @product_category.destroy
      redirect_to :product_categories, :flash => { :notice => t('kkt_shoppe.product_category.destroy_notice') }
    end

    private

    def safe_params
      params[:product_category].permit(:name, :permalink, :description, :image_file, :parent_id, :permalink_includes_ancestors)
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kkt_shoppe-1.3.0 app/controllers/kkt_shoppe/product_categories_controller.rb
kkt_shoppe-1.2.1 app/controllers/kkt_shoppe/product_categories_controller.rb
kkt_shoppe-1.2.0 app/controllers/kkt_shoppe/product_categories_controller.rb
kkt_shoppe-1.1.2 app/controllers/kkt_shoppe/product_categories_controller.rb
kkt_shoppe-1.1.1 app/controllers/kkt_shoppe/product_categories_controller.rb
kkt_shoppe-1.1.0 app/controllers/kkt_shoppe/product_categories_controller.rb