Sha256: 62396f77425c3f8530413ff94b0823a77154f48880feacc459e36d4d5779b088

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 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
    @customer_pages, @customers = paginate :customers, :per_page => 10
  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

14 entries across 14 versions & 1 rubygems

Version Path
backlog-0.12.2 app/controllers/customers_controller.rb
backlog-0.12.1 app/controllers/customers_controller.rb
backlog-0.12.4 app/controllers/customers_controller.rb
backlog-0.12.3 app/controllers/customers_controller.rb
backlog-0.13.1 app/controllers/customers_controller.rb
backlog-0.13.0 app/controllers/customers_controller.rb
backlog-0.14.0 app/controllers/customers_controller.rb
backlog-0.14.1 app/controllers/customers_controller.rb
backlog-0.14.3 app/controllers/customers_controller.rb
backlog-0.14.2 app/controllers/customers_controller.rb
backlog-0.15.0 app/controllers/customers_controller.rb
backlog-0.14.4 app/controllers/customers_controller.rb
backlog-0.15.1 app/controllers/customers_controller.rb
backlog-0.16.0 app/controllers/customers_controller.rb