Sha256: b64a20ff03668f4e3357d7ed5e51afb017ea9e6bdb7478348bf118ca0e982c73
Contents?: true
Size: 1.13 KB
Versions: 42
Compression:
Stored size: 1.13 KB
Contents
class CustomersController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @customers = Customer.paginate :page => params[:page] end def show @customer = Customer.find(params[:id]) end def new @customer = Customer.new end def create @customer = Customer.new(params[:customer]) if @customer.save flash[:notice] = 'Customer was successfully created.' redirect_to :action => 'list' else render :action => 'new' end end def edit @customer = Customer.find(params[:id]) end def update @customer = Customer.find(params[:id]) if @customer.update_attributes(params[:customer]) flash[:notice] = 'Customer was successfully updated.' redirect_to :action => 'show', :id => @customer else render :action => 'edit' end end def destroy Customer.find(params[:id]).destroy redirect_to :action => 'list' end end
Version data entries
42 entries across 42 versions & 1 rubygems