daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Feb 19th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top