Class: CartItemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CartItemsController
- Defined in:
- app/controllers/cart_items_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
RESTful equiv of add.
- #destroy ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
RESTful equiv of add
6 7 8 9 |
# File 'app/controllers/cart_items_controller.rb', line 6 def create persist_cart if @cart.new_record? @cart.add_item(find_cartable) end |
#destroy ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/cart_items_controller.rb', line 20 def destroy if @cart_item.destroy flash[:notice] = t(:cart_item_removed) redirect_to cart_path(@cart) else flash[:notice] = t(:cart_update_failed) end end |
#update ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/cart_items_controller.rb', line 11 def update if @cart_item.update_attributes(params[:cart_item]) flash[:notice] = t(:cart_updated) redirect_to cart_path(cart) else flash[:notice] = t(:cart_update_failed) end end |