Class: CartController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CartController
- Defined in:
- lib/generators/templates/cart_controller.rb
Instance Method Summary collapse
Instance Method Details
#add_to_cart ⇒ Object
3 4 5 6 7 8 |
# File 'lib/generators/templates/cart_controller.rb', line 3 def add_to_cart product = Product.find(params[:id]) @cart = find_cart @cart.add_item(product) redirect_to :back end |
#empty ⇒ Object
17 18 19 |
# File 'lib/generators/templates/cart_controller.rb', line 17 def empty empty_cart end |
#remove_from_cart ⇒ Object
10 11 12 13 14 15 |
# File 'lib/generators/templates/cart_controller.rb', line 10 def remove_from_cart product = Product.find(params[:id]) @cart = find_cart @cart.remove_item(product) redirect_to :back end |
#show ⇒ Object
21 22 23 |
# File 'lib/generators/templates/cart_controller.rb', line 21 def show @cart = cart end |