Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_to_cart
- @cart = find_cart
- product = Product.find(params[:id])
- quantity = params[:quantity]
- quantity ||= 1
- if quantity.to_i > product.quantity.to_i
- logger.info "This product only has #{product.quantity.to_i} remaining."
- render :nothing => true, :status => 400 and return
- else
- @cart.add_product(product, quantity.to_i)
- show_cart and return
- end
- end
Add Comment
Please, Sign In to add comment