Return to Snippet

Revision: 2864
at April 30, 2007 00:57 by winson


Updated Code
# Initialize shopping cart.
  def initialize_cart
    # #1
    # --
    # if session[:cart_id]
    #  @cart = Cart.find(session[:cart_id])
    # else
    #  @cart = Cart.create
    #  session[:cart_id] = @cart.id
    # end
    
    # #2
    # --
    # if session[:cart]
    #  @cart = session[:cart]
    # else
    #  @cart = Cart.create
    #  session[:cart] = @cart
    # end
    
    # #3
    @cart = session[:cart] ||= Cart.create
  end

Revision: 2863
at April 30, 2007 00:56 by winson


Initial Code
  # Initialize shopping cart.
  def initialize_cart
    # #1
    # --
    # if session[:cart_id]
    #  @cart = Cart.find(session[:cart_id])
    # else
    #  @cart = Cart.create
    #  session[:cart_id] = @cart.id
    # end
    
    # #2
    # --
    # if session[:cart]
    #  @cart = session[:cart]
    # else
    #  @cart = Cart.create
    #  session[:cart] = @cart
    # end
    
    # #3
    @cart = session[:cart] ||= Cart.create
  end

Initial URL


Initial Description


Initial Title
My initialize cart

Initial Tags
textmate

Initial Language
Rails