Class: Shoppe::CustomersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'app/controllers/shoppe/customers_controller.rb', line 21

def create
  @customer = Shoppe::Customer.new(safe_params)
  if @customer.save
    redirect_to @customer, :flash => {:notice => "Customer has been created successfully"}
  else
    render :action => "new"
  end
end

#destroyObject



38
39
40
41
# File 'app/controllers/shoppe/customers_controller.rb', line 38

def destroy
  @customer.destroy
  redirect_to customers_path, :flash => {:notice => "Customer has been deleted successfully"}
end

#indexObject



7
8
9
10
# File 'app/controllers/shoppe/customers_controller.rb', line 7

def index
  @query = Shoppe::Customer.ordered.page(params[:page]).search(params[:q])
  @customers = @query.result
end

#newObject



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

def new
  @customer = Shoppe::Customer.new
end

#searchObject



43
44
45
46
# File 'app/controllers/shoppe/customers_controller.rb', line 43

def search
  index
  render :action => "index"
end

#showObject



16
17
18
19
# File 'app/controllers/shoppe/customers_controller.rb', line 16

def show
  @addresses = @customer.addresses.ordered.load
  @orders = @customer.orders.ordered.load
end

#updateObject



30
31
32
33
34
35
36
# File 'app/controllers/shoppe/customers_controller.rb', line 30

def update
  if @customer.update(safe_params)
    redirect_to @customer, :flash => {:notice => "Customer has been updated successfully"}
  else
    render :action => "edit"
  end
end