Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

can't store non-activerecord models in session

#1864

With the attached test case, the resulting error is seen with Rails 2.3Rc1:

/!\ FAILSAFE /!\ Tue Feb 03 18:25:11 -0500 2009 Status: 500 Internal Server Error undefined class/module Cart

/home/rubys/.gem/ruby/1.8/gems/activesupport-2.3.0/lib/active_support/message_verifier.rb:36:in `dump'

The same test works with Rails 2.2.2.

Reported by Sam Ruby · February 3rd, 2009 @ 11:38 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.

    Classic problem: Marshal.load doesn't invoke const_missing.

    It works in 2.2.2 because the Cart constant is already set when the session is unmarshaled. Not sure why this changed in 2.3.

    February 4th, 2009 @ 07:00 PM

  2. Sam Ruby
    Sam Ruby

    Fixing that will simply let me move onto the next problem.

    /!\ FAILSAFE /!\  Tue Feb 03 21:02:03 -0500 2009
      Status: 500 Internal Server Error
      You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.include?
        /home/rubys/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'
    

    There appears to be a few places where there is an assumption that objects in sessions are ActiveRecords.

    February 4th, 2009 @ 07:04 PM

  3. josh
    josh
    • State changed from new to open

    So is this an AR specific problem? Storing Arrays and nested hashes still works I'm assuming.

    None of this was intentional and we should have it fixed for the final 2.3 release.

    February 4th, 2009 @ 07:21 PM

  4. Sam Ruby
    Sam Ruby

    It is cool that it is not intentional.

    My guess -- and it is just a guess -- that from a code perspective there may be a number of unrelated small problems. But, and again this is just a guess: there may be a gaping hole in the test suite.

    I have what amounts to an integration test, namely a script that implements the depot application in the Agile Web Development with Rails book, as well as a few other small scenarios. It works on 2.2.2, except for one part that was a regression in that release. It doesn't get very far with 2.3RC0.

    It is not currently structured in a way that enables it to be immediately picked up as such, but I'd like to work with somebody to use this to enhance the test suite for Rails. I'd be willing to do the bulk of the work.

    February 4th, 2009 @ 08:36 PM

  5. josh
    josh

    Note to self: See 2-2-stable CGIRequest#stale_session_check! for the rescue method catch these types of errors.

    February 5th, 2009 @ 11:22 PM

  6. Michael Koziarski
    Michael Koziarski

    I think this is caused because we've pushed out the session saving till outside the dispatch hook.

    This means we're marshalling the using 'broken vestigial' constants mentioned in #1339 AR::Base should not be nuking its children, just because it lost interest.

    February 5th, 2009 @ 11:56 PM

  7. josh
    josh
    • State changed from open to resolved

    It looks like this commit solved the specific issue.

    http://github.com/rails/rails/co...

    Please open new tickets for any related issues and assign them to me.

    February 8th, 2009 @ 05:13 PM