Guest User

Untitled

a guest
May 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class Purchase
  2. def initialize(cart_item_ids)
  3. @cart_item_ids = cart_item_ids
  4. end
  5.  
  6. def has_cart_items?
  7. !@cart_item_ids.empty?
  8. end
  9.  
  10. def paypal_url
  11. # ...
  12. end
  13. end
  14.  
  15. class PurchasesController < ActionController::Base
  16. def create
  17. @purchase = Purchase.new(session[:cart_items])
  18. if @purchase.has_cart_items?
  19. redirect_to @purchase.paypal_url
  20. else
  21. flash[:notice] = "Your shopping cart is empty. Please add a product and try again."
  22. redirect_to "/store"
  23. end
  24. end
  25. end
  26.  
  27. map.resources :purchases
Add Comment
Please, Sign In to add comment