The method in the AWDwR book of storing the entire Cart object in a session is a little strange, and I wouldn't recommend it. He points this out in the 2nd edition and says you should really store the cart in a database and just reference the "id" of the cart in the session. This is because, if you ever change the Cart class, then the changes will not take effect on the already instantiated Cart objects in the sessions. You will need to clear out the sessions or somehow update them to the updated Cart model. Ultimately though, it is much easier to just store it in the database. I have no clue why he teaches you the "wrong" way to do it, and it's one of my biggest peeves about the book.
Regarding your specific problem, there's probably some way to read a given session's content in Rails, but I don't know how off the top of my head.
Last edited by ryanb (2006-08-15 19:52:07)
- Free Ruby on Rails Screencasts