Sha256: a166917557853d1cb2c244bca58a136643f7bd756710042da32cb74f6edbaee7

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

module Tienda
  class ProductCategoriesController < Tienda::ApplicationController

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

    def index
      @product_categories = Tienda::ProductCategory.ordered.all
    end

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

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

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

    private

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

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tienda-2.0.1 app/controllers/tienda/product_categories_controller.rb
tienda-1.1.2 app/controllers/tienda/product_categories_controller.rb
tienda-1.1.1 app/controllers/tienda/product_categories_controller.rb
tienda-1.1.0 app/controllers/tienda/product_categories_controller.rb
tienda-1.0.0 app/controllers/tienda/product_categories_controller.rb