1 class CoitemController < ApplicationController
4 render :action => 'list'
7 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
8 verify :method => :post, :only => [ :destroy, :create, :update ],
9 :redirect_to => { :action => :list }
12 @coitem_pages, @coitems = paginate :coitems, :per_page => 10
16 @coitem = Coitem.find(params[:id])
24 @coitem = Coitem.new(params[:coitem])
26 flash[:notice] = 'Coitem was successfully created.'
27 redirect_to :action => 'list'
29 render :action => 'new'
34 @coitem = Coitem.find(params[:id])
38 @coitem = Coitem.find(params[:id])
39 if @coitem.update_attributes(params[:coitem])
40 flash[:notice] = 'Coitem was successfully updated.'
41 redirect_to :action => 'show', :id => @coitem
43 render :action => 'edit'
48 Coitem.find(params[:id]).destroy
49 redirect_to :action => 'list'
52 # Awesome, paginating overdue list, ordered by customer
54 @coitem_pages, @coitems = paginate :coitems, :per_page => 50, :conditions => "due_date < DATE('NOW', 'LOCALTIME')", :order => "customer_id"
55 render :action => 'list'
59 render :action => 'return'
63 rentable_id = params[:rentable_id]
64 @rentable = Rentable.find_by_id(rentable_id)
67 flash[:error] = "Unable to find this rentable"
68 redirect_to :action => :return
72 @coitem = Coitem.find_by_rentable_id(rentable_id)
74 flash[:error] = "This item is not checked out!"
75 redirect_to :action => :return
79 # Check if the item is overdue
81 @coitem.customer.debt += @coitem.late_fee
88 flash[:notice] = "Successfully returned item"
89 redirect_to :action => :return