Class: Admin::CustomersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::CustomersController
- Defined in:
- app/controllers/tang/admin/customers_controller.rb
Instance Method Summary collapse
- #apply_coupon ⇒ Object
- #coupon ⇒ Object
-
#destroy ⇒ Object
DELETE /customers/1.
-
#edit ⇒ Object
GET /customers/1/edit.
-
#index ⇒ Object
GET /customers.
- #remove_coupon ⇒ Object
-
#show ⇒ Object
GET /customers/1.
-
#update ⇒ Object
PATCH/PUT /customers/1.
Instance Method Details
#apply_coupon ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 41 def apply_coupon @customer = Tang.customer_class.find(params[:customer_id]) @coupon = Coupon.find(params[Tang.customer_class.to_s.downcase][:coupon_id]) ApplyCustomerDiscount.call(@customer, @coupon) redirect_to admin_customer_url(@customer), notice: 'Coupon was successfully applied.' end |
#coupon ⇒ Object
37 38 39 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 37 def coupon @customer = Tang.customer_class.find(params[:customer_id]) end |
#destroy ⇒ Object
DELETE /customers/1
32 33 34 35 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 32 def destroy @customer.destroy redirect_to admin_customers_url, notice: 'Customer was successfully destroyed.' end |
#edit ⇒ Object
GET /customers/1/edit
19 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 19 def edit; end |
#index ⇒ Object
GET /customers
8 9 10 11 12 13 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 8 def index @customers = Tang.customer_class .where.not(stripe_id: nil) .paginate(page: params[:page]) .order(:email) end |
#remove_coupon ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 48 def remove_coupon @customer = Tang.customer_class.find(params[:customer_id]) RemoveCustomerDiscount.call(@customer) redirect_to admin_customer_url(@customer), notice: 'Coupon was successfully removed.' end |
#show ⇒ Object
GET /customers/1
16 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 16 def show; end |
#update ⇒ Object
PATCH/PUT /customers/1
22 23 24 25 26 27 28 29 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 22 def update if @customer.update(customer_params) UpdateCustomer.call(@customer) redirect_to admin_customer_path(@customer), notice: 'Customer was successfully updated.' else render :edit end end |