Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Purchase
- def initialize(cart_item_ids)
- @cart_item_ids = cart_item_ids
- end
- def has_cart_items?
- !@cart_item_ids.empty?
- end
- def paypal_url
- # ...
- end
- end
- class PurchasesController < ActionController::Base
- def create
- @purchase = Purchase.new(session[:cart_items])
- if @purchase.has_cart_items?
- redirect_to @purchase.paypal_url
- else
- flash[:notice] = "Your shopping cart is empty. Please add a product and try again."
- redirect_to "/store"
- end
- end
- end
- map.resources :purchases
Add Comment
Please, Sign In to add comment