Quoting Scott Olmsted <[email protected]>: > def get_cart > @cart = @user.cart unless @user.blank? > @cart = Cart.find_by_id(session[:cart_id]) if @cart.blank? && > !session[:cart_id].blank? > end > > While it is not required that one sign in to make a purchase, if I am > signed in, then get_cart first goes and looks for a cart of mine in > the database. This makes informal testing difficult because it means > I can't discard a cart by deleting the cookie, I can't start over! > > A more serious problem with tying a cart to a user is that someone > could add items to a new cart, then log in and find themselves > looking at an old cart they had when last logged in, losing the newer > cart they were using. Maybe the developer wanted to make sure a > user's cart was never lost, but this is a bad side effect. > > So am I right in thinking that a cart should not be tied to a user? > Or at least the logic in get_cart should be reversed: look first for > a cart pointed to by the session, then look for one belonging to the user?
Does the UI imply some sort of "save for later" feature? I am guessing that this logic is trying to let users log in to save their cart to finalized the purchase later. But that only really works if carts disappear when the order is placed. Otherwise you might get an old cart full of stuff you already received. -- Cynthia Kiser [email protected] -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
