class Admin::ItemsController < Admin::ApplicationController def index @items = Item.find(:all, :include => :category) end def new @item = Item.new end def create @item = Item.new(params[:item]) if @item.save flash[:notice] = 'Item was successfully created.' redirect_to :controller => 'items', :action => 'show', :id => @item, :new => 'true' else render :action => 'new' end end def show @item = Item.find(params[:id]) end def update @item = Item.find(params[:id]) if @item.update_attributes(params[:item]) flash[:notice] = "The item was updated successfully." else flash[:error] = "This item could not be updated. Please try again." end render :action => 'show' end def destroy @item = Item.find(params[:id]) if @item.destroy flash[:notice] = "The item was deleted successfully." else flash[:notice] = "This item could not be deleted. Please try again." end redirect_to admin_items_path end end