Posted By

winson on 04/30/07


Tagged

textmate controller application cart


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


My initialize cart


 / Published in: Rails
 

  1. # Initialize shopping cart.
  2. def initialize_cart
  3. # #1
  4. # --
  5. # if session[:cart_id]
  6. # @cart = Cart.find(session[:cart_id])
  7. # else
  8. # @cart = Cart.create
  9. # session[:cart_id] = @cart.id
  10. # end
  11.  
  12. # #2
  13. # --
  14. # if session[:cart]
  15. # @cart = session[:cart]
  16. # else
  17. # @cart = Cart.create
  18. # session[:cart] = @cart
  19. # end
  20.  
  21. # #3
  22. @cart = session[:cart] ||= Cart.create
  23. end

Report this snippet  

You need to login to post a comment.