All pastes #568787 Raw Edit

Stuff

public ruby v1 · immutable
·published 2007-06-15 19:41 UTC
rendered paste body
class AdminCategoryController < ApplicationController	before_filter :authorize	layout "admin"  def index    list    render :action => 'list'  end  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)  verify :method => :post, :only => [ :destroy, :create, :update ],         :redirect_to => { :action => :list }  def list  	@parent_categories = ParentCategory.find(:all)    @category_pages, @categories = paginate :categories, :per_page => 50  end  	def list_parent_category		@parent_categories = ParentCategory.find(:all)		@ctgs = Category.find(:all, :conditions => ["parent_category_id =?", params[:id]])		#@ctg_pages, @ctgs = paginate :ctgs, :per_page => 10	end  def show    @category = Category.find(params[:id])  end  def new  	@parent_categories = ParentCategory.find_all    @category = Category.new  end  def create    @category = Category.new(params[:category])    if @category.save      flash[:notice] = 'Category was successfully created.'      redirect_to :action => 'list'    else      render :action => 'new'    end  end  def edit  	@parent_categories = ParentCategory.find_all    @category = Category.find(params[:id])  end  def update    @category = Category.find(params[:id])    if @category.update_attributes(params[:category])      flash[:notice] = 'Category was successfully updated.'      redirect_to :action => 'show', :id => @category    else      render :action => 'edit'    end  end  def destroy    Category.find(params[:id]).destroy    redirect_to :action => 'list'  endend