Class: SimpleCart::CartsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SimpleCart::CartsController
- Defined in:
- app/controllers/simple_cart/carts_controller.rb
Instance Method Summary collapse
- #add ⇒ Object
- #checkout ⇒ Object
- #clear ⇒ Object
- #destroy ⇒ Object
- #remove ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add ⇒ Object
15 16 17 18 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 15 def add @cart.add_item("#{params[:klass]}_#{params[:item_id]}".to_s, params[:qty].to_i) redirect_to cart_url end |
#checkout ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 8 def checkout @order = @cart.build_order @order.save session.delete(:cart) redirect_to order_checkout_index_path(@order) end |
#clear ⇒ Object
35 36 37 38 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 35 def clear session.delete(:cart) redirect_to cart_path end |
#destroy ⇒ Object
25 26 27 28 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 25 def destroy @cart.remove_item(params[:id]) render :show end |
#remove ⇒ Object
30 31 32 33 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 30 def remove @cart.remove_item(params[:id]) render :show end |
#show ⇒ Object
5 6 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 5 def show end |
#update ⇒ Object
20 21 22 23 |
# File 'app/controllers/simple_cart/carts_controller.rb', line 20 def update @cart.update_items(params) render :show end |