mperham/dalli — Issue #158: uninitialized constant ActionDispatch::Session
Author: patsch
Created: 2012-01-14 09:02:34+00:00
State: open

I'm trying to use Dalli with Rails 2.3.11 & Passenger 2.2.15 and am getting a NameError - uninitialized constant ActionDispatch::Session from this line in environment.rb:

ObjectSpace.each_object(ActionDispatch::Session::DalliStore) { |obj| obj.reset }

My environment.rb has:

config.gem 'dalli'

in the Rails::Initializer block as well as the recommended block for passenger - as I am only using it for session storage I outcommented the Object cache part (which also threw an error about the reset method not known btw):

if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# Reset Rails's object cache
# Only works with DalliStore
# Rails.cache.reset if forked

# Reset Rails's session store
# If you know a cleaner way to find the session store instance, please let me know
ObjectSpace.each_object(ActionDispatch::Session::DalliStore) { |obj| obj.reset }
end
end

I also have this in initializers/session_store.rb:

# Session cache
ActionController::Base.session = {
:namespace => 'sessions',
:expire_after => 20.minutes.to_i,
:memcache_server => ['localhost:11211'],
:key => "_myapp_session",
:secret => "where 1 the hell11 is8 this 7 magic place089" }

require 'action_controller/session/dalli_store'

ActionController::Base.session_store = :dalli_store

Thanks for your help,
Patrick