Sha256: 512f8fc6c1c01ee7aab673b94cac91492aad4394abbbda8967a853bbd634d9ee

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

module Shoppe
  class ProductCategoriesController < Shoppe::ApplicationController

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

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

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

    def create
      @product_category = Shoppe::ProductCategory.new(safe_params)
      if @product_category.save
        redirect_to :product_categories, :flash => { :notice => t('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('shoppe.product_category.update_notice') }
      else
        render :action => "edit"
      end
    end

    def destroy
      @product_category.destroy
      redirect_to :product_categories, :flash => { :notice => t('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

5 entries across 5 versions & 2 rubygems

Version Path
shoppe-1.0.9 app/controllers/shoppe/product_categories_controller.rb
shoppe-1.0.8 app/controllers/shoppe/product_categories_controller.rb
kylekthompson-shoppe-1.0.7 app/controllers/shoppe/product_categories_controller.rb
shoppe-1.0.7 app/controllers/shoppe/product_categories_controller.rb
shoppe-1.0.6 app/controllers/shoppe/product_categories_controller.rb