Sha256: b999b2ad0aa5907c8d3f9b2af6af63971c3a276e0720c48549390a9abfbf4b05

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module Kublog
  class CategoriesController < ApplicationController
    
    skip_filter :require_admin, :only => [:show]
    
    def show
      @category = Category.find(params[:id])
      @presenter = PostsPresenter.new(@category)
      respond_to do |format|
        format.atom { render "/kublog/posts/index", :layout => false }
        format.rss  { redirect_to category_path(@category, :format => :atom), :status => :moved_permanently }
        format.html { render "/kublog/posts/index" }
      end
    end
    
    def create
      @category = Category.new(params[:category])
      respond_to do |format|
        if @category.save
          format.json { render :json => @category }
        else
          format.json { render :json => @category.errors.messages, :status => 'unprocessable_entity' }
        end
      end
    end
    
    def update
      @category = Category.find(params[:id])
      respond_to do |format|
        if @category.update_attributes(params[:category])
          format.json { render :json => @category }
        else
          format.json { render :json => @category.errors.messages, :status => 'unprocessable_entity' }
        end
      end
    end
    
    def destroy
      @category = Category.find(params[:id])
      @category.destroy
      respond_to do |format|
        format.json{ render :json => @category }
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kublog-0.0.1.1 app/controllers/kublog/categories_controller.rb