Class: PowerShop::CartController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PowerShop::CartController
- Defined in:
- app/controllers/power_shop/cart_controller.rb
Overview
Controller represents methods for cart
Instance Method Summary collapse
-
#add_product ⇒ Object
Public: add products to shopping cart if request is simple post redirects back if request is ajax respond with json message.
- #delete_product ⇒ Object
-
#show ⇒ Object
Pubclic: show cart page TODO: preload associations.
Methods inherited from ApplicationController
Instance Method Details
#add_product ⇒ Object
Public: add products to shopping cart if request is simple post redirects back if request is ajax respond with json message
Returns text/html or text/json
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/power_shop/cart_controller.rb', line 13 def add_product cart.add(@product, @product.price, params.fetch(:quantity, 1)) if request.xhr? render_json_cart else redirect_to :back end end |
#delete_product ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/power_shop/cart_controller.rb', line 23 def delete_product # TODO: 99 - its hack for remove all items :) cart.remove(@product, 99) redirect_to :back end |
#show ⇒ Object
Pubclic: show cart page TODO: preload associations
Returns text/html
33 34 35 |
# File 'app/controllers/power_shop/cart_controller.rb', line 33 def show @cart = cart end |