Class: CustomersController

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

Constant Summary

Constants included from Localization

Localization::LOCALIZED_STRINGS

Instance Method Summary collapse

Methods inherited from ApplicationController

in_place_edit_for, #initialize

Methods included from ApplicationHelper

#back_or_link_to, #detour?, #detour_to, #display_notice, #h, #image_button_to, #image_detour_to, #image_link_to, #image_link_to_remote, #insert, #record, #resolution_image, #t, #update_task, #with_detour

Methods included from Localization

#l, load_localized_strings, #valid_language?

Constructor Details

This class inherits a constructor from ApplicationController

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/customers_controller.rb', line 23

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

#destroyObject



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

def destroy
  Customer.find(params[:id]).destroy
  redirect_to :action => 'list'
end

#editObject



33
34
35
# File 'app/controllers/customers_controller.rb', line 33

def edit
  @customer = Customer.find(params[:id])
end

#indexObject



2
3
4
5
# File 'app/controllers/customers_controller.rb', line 2

def index
  list
  render :action => 'list'
end

#listObject



11
12
13
# File 'app/controllers/customers_controller.rb', line 11

def list
  @customers = Customer.paginate :page => params[:page]
end

#newObject



19
20
21
# File 'app/controllers/customers_controller.rb', line 19

def new
  @customer = Customer.new
end

#showObject



15
16
17
# File 'app/controllers/customers_controller.rb', line 15

def show
  @customer = Customer.find(params[:id])
end

#updateObject



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

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