1 class CustomerController < ApplicationController
4 # Make sure that the user has logged in before they can take any action
5 before_filter :authorize
8 render :action => 'index'
11 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
12 verify :method => :post, :only => [ :destroy, :create, :update ],
13 :redirect_to => { :action => :list }
16 @customer_pages, @customers = paginate :customers, :per_page => 10
20 @customer = Customer.find(params[:id])
24 @customer = Customer.new
28 @customer = Customer.new(params[:customer])
30 flash[:notice] = 'Customer was successfully created.'
31 redirect_to :action => 'list'
33 render :action => 'new'
38 @customer = Customer.find(params[:id])
42 @customer = Customer.find(params[:id])
43 if @customer.update_attributes(params[:customer])
44 flash[:notice] = 'Customer was successfully updated.'
45 redirect_to :action => 'show', :id => @customer
47 render :action => 'edit'
52 Customer.find(params[:id]).destroy
53 redirect_to :action => 'list'
59 @customers = Customer.find(:all, :conditions => ["name like ?", @query[0]+"%"])
60 render :action => 'searchresults'
62 render :action => 'search'