Class: Shoppe::CustomersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Shoppe::CustomersController
- Defined in:
- app/controllers/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
20 21 22 23 24 25 26 27 |
# File 'app/controllers/shoppe/customers_controller.rb', line 20 def create @customer = Shoppe::Customer.new(safe_params) if @customer.save redirect_to @customer, flash: { notice: t('shoppe.customers.created_successfully') } else render action: 'new' end end |
#destroy ⇒ Object
37 38 39 40 |
# File 'app/controllers/shoppe/customers_controller.rb', line 37 def destroy @customer.destroy redirect_to customers_path, flash: { notice: t('shoppe.customers.deleted_successfully') } end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/shoppe/customers_controller.rb', line 6 def index @query = Shoppe::Customer.ordered.page(params[:page]).search(params[:q]) @customers = @query.result end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/shoppe/customers_controller.rb', line 11 def new @customer = Shoppe::Customer.new end |
#search ⇒ Object
42 43 44 45 |
# File 'app/controllers/shoppe/customers_controller.rb', line 42 def search index render action: 'index' end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/shoppe/customers_controller.rb', line 15 def show @addresses = @customer.addresses.ordered.load @orders = @customer.orders.ordered.load end |
#update ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/shoppe/customers_controller.rb', line 29 def update if @customer.update(safe_params) redirect_to @customer, flash: { notice: t('shoppe.customers.updated_successfully') } else render action: 'edit' end end |