This project is archived and is in readonly mode.

#1876 ✓ invalid
bille2

uninitialized constant ActionController::Session::MemoryStore

Reported by bille2 | February 4th, 2009 @ 08:23 PM | in 2.x

I have installed the 2.3RC1 and as start an existing projet, that is working on 2.2 the server stop its launch with the error:

** /Library/Ruby/Gems/1.8/gems/activesupport-2.3.0/lib/active_support/dependencies.rb:440:in load_missing_constant': uninitialized constant ActionController::Session::MemoryStore (NameError) **

My environment.rb contains the following line * config.action_controller.session_store = :memory_store *

The error disappear when I change it to :active_record_store

Comments and changes to this ticket

  • DHH

    DHH February 6th, 2009 @ 02:01 PM

    • State changed from “new” to “invalid”

    The MemoryStore has been killed off. I'd recommend either using active_record_store or, even better, start using the default cookie store.

  • samur araujo

    samur araujo April 7th, 2009 @ 07:09 PM

    Hi all, I can not see a reason to remove memory_store from rails 2.3 sessions. Sometimes it is too much simple to configure a session as : config.action_controller.session_store = :memory_store

    I do not feel comfortable in use active_record_store or mem_cache_store in my app. My application does not have a database, so I am not using the active_record_store, and I do not want to configure one because all my data comes from Semantic Web endpoints.

    Also, I don't want to configure a cache server to store users' sessions because my app is too small to demand such effort.

    I thing that :memory_store has its applicability and should be kept in future version.

    Regards, Samur Araújo Msc. Compute Science - PUC-Rio - Brasil

  • bshand

    bshand November 20th, 2009 @ 02:21 PM

    :memory_store is useful only in very limited circumstances -- very simple servers where session data must be kept secret, or servers which require session fixation for other reasons. But here is a re-implementation for Rails 2.3, in case you really need it. Put the file into It's not threadsafe, just like the original.

    # Port of old CGI::Session::MemoryStore to Rails 2.3
    module ActionController
      module Session
        # In-memory session storage class.
        #
        # Implements session storage as a global in-memory hash.  Session
        # data will only persist for as long as the ruby interpreter 
        # instance does.
        class MemoryStore < AbstractStore
          GLOBAL_HASH_TABLE = {} #:nodoc:
    
          private
            def get_session(env, sid)
              sid ||= generate_sid
              session = GLOBAL_HASH_TABLE[sid] || {}
              session = AbstractStore::SessionHash.new(self, env).merge(session)
              [sid, session]
            end
    
            def set_session(env, sid, session_data)
              GLOBAL_HASH_TABLE[sid] = session_data
              return true
            end
        end
      end
    end unless RAILS_GEM_VERSION =~ /^([01]\.|2\.[012]\.)/
    
  • bshand

    bshand November 20th, 2009 @ 02:24 PM

    Create a file in config/initializers/ containing the above code; then your existing session configuration will continue to work in Rails 2.3.

Create your profile

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

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

People watching this ticket

Pages