Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created January 13, 2011 16:57
Show Gist options
  • Save datapimp/778175 to your computer and use it in GitHub Desktop.
Save datapimp/778175 to your computer and use it in GitHub Desktop.
class CategoriesController < ApplicationController
before_filter :require_admin
before_filter :get_category, :only => [:show,:edit,:update,:destroy]
respond_to :html, :xml, :json
responders :flash, :http_cache, :collections
def index
respond_with( @categories = Category.query(params) )
end
def show
respond_with( @category )
end
def edit
respond_with( @category )
end
def update
@category.update_attributes(params[:category])
respond_with( @category )
end
def new
respond_with( @category = Category.new )
end
def create
respond_with( @category = Category.create(params[:category]) )
end
def destroy
@category.destroy
respond_with( @category )
end
protected
def get_category
@category = Category.find( params[:id].to_i )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment