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
42 43 44 45 46 47 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 42 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
38 39 40 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 38 def coupon @customer = Tang.customer_class.find(params[:customer_id]) end |
#destroy ⇒ Object
DELETE /customers/1
33 34 35 36 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 33 def destroy @customer.destroy redirect_to admin_customers_url, notice: 'Customer was successfully destroyed.' end |
#edit ⇒ Object
GET /customers/1/edit
19 20 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 19 def edit end |
#index ⇒ Object
GET /customers
8 9 10 11 12 |
# 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
49 50 51 52 53 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 49 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
15 16 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 15 def show end |
#update ⇒ Object
PATCH/PUT /customers/1
23 24 25 26 27 28 29 30 |
# File 'app/controllers/tang/admin/customers_controller.rb', line 23 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 |