Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
Coitem.find(params[:id]).destroy
redirect_to :action => 'list'
end
+
+ # Awesome, paginating overdue list, ordered by customer
+ def overdue
+ @coitem_pages, @coitems = paginate :coitems, :per_page => 50, :conditions => "due_date < DATE('NOW', 'LOCALTIME')", :order => "customer_id"
+ render :action => 'list'
+ end
end
validates_associated :customer
validates_associated :rentable
+ def overdue?
+ return due_date < Time.now.to_date
+ end
+
protected
def validate
errors.add(:customer_id, "does not exist is the database") if customer.nil?
<tr>
<th>Customer</th>
<th>Rentable</th>
+ <th>Overdue</th>
<% for column in Coitem.content_columns %>
<th><%= column.human_name %></th>
<% end %>
<tr>
<td><%=h coitem.customer.name %></td>
<td><%=h coitem.rentable.title %></td>
+ <td><%=h coitem.overdue? %></td>
<% for column in Coitem.content_columns %>
<td><%=h coitem.send(column.name) %></td>
<% end %>