Class: Ecom2::CartController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Ecom2::CartController
- Defined in:
- app/controllers/ecom2/cart_controller.rb
Instance Method Summary collapse
Instance Method Details
#add ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/ecom2/cart_controller.rb', line 7 def add @cart.save session[:cart_id] = @cart.id product = Product.find(params[:id]) item = LineItem.new item.make_items(@cart.id, product.id, product.base_price) @cart.recalculate_price! flash[:notice] = "Product Added to Cart" redirect_to cart_path end |
#remove ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/ecom2/cart_controller.rb', line 17 def remove item = @cart.line_items.find(params[:id]) item.destroy @cart.recalculate_price! flash[:notice] = "Product Deleted from Cart" redirect_to cart_path end |
#show ⇒ Object
25 26 27 |
# File 'app/controllers/ecom2/cart_controller.rb', line 25 def show end |