class Admin::AuctionsController < Admin::ApplicationController def index @auctions = Auction.find(:all, :order => :datetime) end def show @auction = Auction.find(params[:id]) end def item @item = AuctionItem.find(params[:id]) end def add_item render :text => Auction.find(params[:id]).inspect # @item = AuctionItem.create(:name => 'New item') # @item.images.create(params[:attachment_metadata]); # redirect_to admin_auctions_path end def delete_item @item = AuctionItem.find(params[:id]) @item.images.destroy_all @item.destroy render :nothing => true end def update_positions params[:images].each_with_index do |id, position| AuctionItem.update(id, :position => position+1) end render :nothing => true end def new @auction = Auction.new end def create @auction = Auction.new(params[:auction]) if @auction.save flash[:notice] = 'Auction was successfully created.' redirect_to :action => 'show', :id => @auction.id, :new => 'true' else render :action => 'new' end end def edit @auction = Auction.find(params[:id]) @auction.update_attributes(params[:auction]) render :partial => "auctioninfo", :object => @auction, :layout => false end def update @auction = Auction.find(params[:id]) if @auction.update_attributes(params[:auction]) flash[:notice] = 'Auction was successfully updated.' redirect_to :action => 'show', :id => @auction else render :action => 'edit' end end def delete Auction.find(params[:id]).destroy render :nothing => true end end