This project is archived and is in readonly mode.

#1864 ✓resolved
Sam Ruby

can't store non-activerecord models in session

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

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.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper February 4th, 2009 @ 07:00 PM

    • 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.

  • Sam Ruby

    Sam Ruby February 4th, 2009 @ 07:04 PM

    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.

  • josh

    josh February 4th, 2009 @ 07:21 PM

    • 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.

  • Sam Ruby

    Sam Ruby February 4th, 2009 @ 08:36 PM

    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.

  • josh

    josh February 5th, 2009 @ 11:22 PM

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

  • Michael Koziarski

    Michael Koziarski February 5th, 2009 @ 11:56 PM

    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.

  • josh

    josh February 8th, 2009 @ 05:13 PM

    • State changed from “open” to “resolved”

    It looks like this commit solved the specific issue.

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>