Class: AddressController

Inherits:
ApplicationController show all
Defined in:
app/controllers/address_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/address_controller.rb', line 7

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

#editObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/address_controller.rb', line 18

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

#listObject



30
31
32
33
34
# File 'app/controllers/address_controller.rb', line 30

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

#newObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/address_controller.rb', line 36

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

#showObject



48
49
50
# File 'app/controllers/address_controller.rb', line 48

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