Sha256: 36a3d9bcd44f91572bb92a95a6a1bc958930067abd215553218a53fc79bf72ad

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

class AddressController < ApplicationController
  verify :only => [ 'show', 'edit', 'destroy' ],
         :params => :id,
         :add_flash => { :notice => 'Missing address ID.' },
         :redirect_to => { :action => 'list' }

  def destroy
    if request.post?
      Address.find(params[:id]).destroy
      flash[:notice] = 'The address was successfully destroyed.'
      redirect_to :action => 'list'
    else
      flash[:notice] = 'Click Destroy to destroy the address.'
      redirect_to :action => 'edit', :id => params[:id]
    end
  end

  def edit
    if request.post?
      @address = Address.find(params[:id])
      if @address.update_attributes(params[:address])
        flash[:notice] = 'The address was successfully edited.'
        redirect_to :action => 'show', :id => @address
      end
    else
      @address = Address.find(params[:id])
    end
  end

  def list
    session[:navList] = :logout
    @address_pages, @addresses = paginate(:addresses)
 
  end

  def new
    if request.post?
      @address = Address.new(params[:address])
      if @address.save
        flash[:notice] = 'A new address was successfully added.'
        redirect_to :action => 'list'
      end
    else
      @address = Address.new
    end
  end

  def show
    @address = Address.find(params[:id])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sugoi-mail-0.1.5 app/controllers/address_controller.rb
sugoi-mail-0.3.0 app/controllers/address_controller.rb
sugoi-mail-0.3.2 app/controllers/address_controller.rb