Created
January 13, 2011 16:57
-
-
Save datapimp/778175 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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