Jeremy McAnally wrote: > It should. Sorry, I'm not sure what that is referring to.
> How are you running your app? If you run it with > script/server, unless you're forcing production mode, you should get a > nice error page with a stack trace, error information, session dump, > etc. > > --Jeremy > All standard stuff: sqlite3 development ruby script/server --> Mongrel However, I just changed my code back to what I posted, then cleared the sessions with: rake db:sessions:clear and now using a Product object as a key in the hash works fine. I think all the massive problems I've had with sessions definitely highlights this point in my book: ------------ ...it's generally a really bad idea to store application-level objects in session data. ... Instead, the recommended practice is to store only simple data in the session: strings, numbers, and so on. Keep your application objects in the database, and then reference them using their primary keys from the session data. AWDWR(3rd) p. 106 ------------- I think the problem with storing objects in sessions is that any little change you make to your code requires that you clear all the session data (and restart the server) because now a previously stored object is not consisted with your new code. Following those guidelines, my Cart class would look like this: class Cart attr_reader :items def initialize @items = {} end def add_item(product) if @items[product.id] @items[product.id] += 1 else @items[product.id] = 1 end end end and that works too. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---