Sha256: 16268242fd2b14bb2e7f67457b2748e7f29a6a17182797393c59f17732173bd0

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

require_dependency "wafflemix/application_controller"

module Wafflemix
  class Admin::CategoriesController < ApplicationController

    layout 'wafflemix/admin'

    def index
      @categories = Category.all
  
      respond_to do |format|
        format.html
        format.json { render json: @categories }
      end
    end

    def show
      @category = Category.find(params[:id])
  
      respond_to do |format|
        format.html
        format.json { render json: @category }
      end
    end

    def new
      @category = Category.new
  
      respond_to do |format|
        format.html
        format.json { render json: @category }
      end
    end

    def edit
      @category = Category.find(params[:id])
    end

    def create
      @category = Category.new(params[:category])
  
      respond_to do |format|
        if @category.save
          format.html { redirect_to admin_categories_path, notice: 'Category was successfully created.' }
          format.json { render json: @category, status: :created, location: @category }
        else
          format.html { render action: "new" }
          format.json { render json: @category.errors, status: :unprocessable_entity }
        end
      end
    end

    def update
      @category = Category.find(params[:id])
  
      respond_to do |format|
        if @category.update_attributes(params[:category])
          format.html { redirect_to admin_categories_path, notice: 'Category was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: "edit" }
          format.json { render json: @category.errors, status: :unprocessable_entity }
        end
      end
    end

    def destroy
      @category = Category.find(params[:id])
      @category.destroy
  
      respond_to do |format|
        format.html { redirect_to admin_categories_path }
        format.json { head :no_content }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wafflemix-0.0.4 app/controllers/wafflemix/admin/categories_controller.rb
wafflemix-0.0.3 app/controllers/wafflemix/admin/categories_controller.rb
wafflemix-0.0.2 app/controllers/wafflemix/admin/categories_controller.rb
wafflemix-0.0.1 app/controllers/wafflemix/admin/categories_controller.rb