Guest User

Untitled

a guest
Mar 6th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. class StoreController < ApplicationController
  2.  
  3. def index
  4. @products = Product.find_products_for_sale
  5. end
  6.  
  7. def add_to_cart
  8. @cart = find_cart
  9. product = Product.find(params[:id])
  10. @cart.add_product(product)
  11. end
  12.  
  13. #Things after this are all private
  14. private
  15.  
  16. def find_cart
  17. session[:cart] ||= Cart.new
  18. end
  19.  
  20. end
Add Comment
Please, Sign In to add comment