Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def add_to_cart
  2. @cart = find_cart
  3. product = Product.find(params[:id])
  4. quantity = params[:quantity]
  5. quantity ||= 1
  6.  
  7. if quantity.to_i > product.quantity.to_i
  8. logger.info "This product only has #{product.quantity.to_i} remaining."
  9. render :nothing => true, :status => 400 and return
  10. else
  11. @cart.add_product(product, quantity.to_i)
  12. show_cart and return
  13. end
  14. end
Add Comment
Please, Sign In to add comment