small medium large xlarge

25 Jun 2009, 18:56
Shane Fera (1 post)

I’m having an odd problem that I don’t quite understand the origin nor solution for.

Everything is working just as the examples step us through in the book, but as I like to take things a little further sometimes I’m experimenting with testing boundaries.

I have 7 unique products created in the database.

I can select any combination of these itesm to add to the cart, only up until the cart contains 5 items.

After that point, my console log indigates I’m getting a HTTP error of 500: “POST /store/add_to_cart/4 HTTP/1.1” 500 60

and nothing is added to the cart.

Before going to Javascript and AJAX steps, this problem was still apparent, but would be a 500 error at the following address:

Or whatever number id of the item I had just attempted to add to the cart.

It’s stumping me because it happens no matter the order I add items, and just breaks at 5. (Edit: I found an order that actually causes it to break after 4 items. Which makes this stranger. It also means that it must be something about the way I’ve entered items I think.

If I’ve missed something from the book, or if any of you have had this issue, please let me know.



07 Aug 2009, 12:15
Crashmac (1 post)

That’s because you are storing items in session[:cart]. Sessions can only contain a limited amount of data, so when the limit is reached, you cannot add any more items(when you get the 500 error, if you then look in you servers log file you will see that the problem was caused by ‘cookie overflow’). In the Agile web development third edition it is mentioned that it is not good to store large amount of data in sessions and it is better to create a Cart an Active Record object and store data in database. But then they don’t show how to do that and thats my problem now because I have no idea how to acopmlish that. So any help would be appreciated.

You must be logged in to comment