Class: KktShoppe::CustomersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- KktShoppe::CustomersController
- Defined in:
- app/controllers/kkt_shoppe/customers_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 21 def create @customer = KktShoppe::Customer.new(safe_params) if @customer.save redirect_to @customer, :flash => {:notice => "Customer has been created successfully"} else render :action => "new" end end |
#destroy ⇒ Object
38 39 40 41 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 38 def destroy @customer.destroy redirect_to customers_path, :flash => {:notice => "Customer has been deleted successfully"} end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 7 def index @query = KktShoppe::Customer.ordered.page(params[:page]).search(params[:q]) @customers = @query.result end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 12 def new @customer = KktShoppe::Customer.new end |
#search ⇒ Object
43 44 45 46 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 43 def search index render :action => "index" end |
#show ⇒ Object
16 17 18 19 |
# File 'app/controllers/kkt_shoppe/customers_controller.rb', line 16 def show @addresses = @customer.addresses.ordered.load @orders = @customer.orders.ordered.load end |
#update ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/kkt_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 |