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.

Rails3 rc env['rack.session.record'] is not initialized in first request

#5233

When creating a new session (by accessing the SessionHash), load_session in AbstractStore is not calling get_session anymore (between beta4 and rc), thus the ActiveRecord session record is not instantiated and env['rack.session.record'] is empty.

This is the relevant code in ./actionpack-3.0.0.rc/lib/action_dispatch/middleware/session/abstract_store.rb

        def load_session(env)
          stale_session_check! do
            if sid = current_session_id(env)
              sid, session = get_session(env, sid)
            else
              sid, session = generate_sid, {}
            end
            [sid, session]
          end
        end

Since my session record is a complex model which also implements session-specific behavior I need to access it even if it is a new session.

I see that this change has been made on purpose to lazy-create the record, however it breaks my usage of sessions and I don't see an alternative approach to have a session model (and not only a hash) in my application without duplicating session tables.

Reported by Daniele Orlandi · July 28th, 2010 @ 05:59 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Daniele Orlandi
    Daniele Orlandi

    Sorry, title has been truncated.... should have read "Rails3 rc env['rack.session.record'] is not initialized in first request"

    Can you edit it?

    July 28th, 2010 @ 06:11 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • Title changed from Rails3 rc to Rails3 rc env['rack.session.record'] is not initialized in first request
    • Importance changed from to Low

    July 29th, 2010 @ 02:49 AM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from abstract_store.rb, rails3.0rc, rails3rc, session to abstract_storerb, rails30rc, rails3rc, session

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:34 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:34 PM

  5. bingbing