This project is archived and is in readonly mode.
Rails 2.3 does not obey config.action_controller.session_store
Reported by Nate Wiger | February 18th, 2009 @ 12:08 AM
Rails 2.3 (edge) does not obey config.action_controller.session_store. If you set:
config.action_controller.session_store = :sql_session_store
Rails does not use the session class. Debug output that I placed in:
vendor/rails/actionpack/lib/action_controller/session_management.rb
Claims that it is loading the class, and this code appears to be referenced:
def session_store=(store)
if store == :active_record_store
self.session_store = ActiveRecord::SessionStore
else
@@session_store = store.is_a?(Symbol) ?
Session.const_get(store.to_s.camelize) :
store
puts "DEBUG: session_store=#{@@session_store}" # prints "SqlSessionStore"
end
end
However, the session store is NOT actually used.
The only way to get Rails to use the session store is by adding this line to config/environments/development.rb
config.middleware.use SqlSessionStore
(Per a hint from Josh Peek). Note that this does not work either:
# config/initializers/session_store.rb
ActionController::Base.session_store = :sql_session_store
In both cases, the setting appears to be ignored somewhere later in Rails.
A Rails 2.3-compatible version of SqlSessionStore is available here for testing: git://github.com/nateware/sql_session_store.git
Comments and changes to this ticket
-
josh February 18th, 2009 @ 12:10 AM
- Milestone cleared.
- State changed from new to open
-
Repository February 20th, 2009 @ 03:21 AM
- State changed from open to resolved
(from [9702636a08e50e9fed9bf76ad620a6a0a109009e]) Lazy evaluate ActionController session store middleware class to pickup custom plugin session stores [#2001 state:resolved] http://github.com/rails/rails/co...
-
Thibaud Guillaume-Gentil February 20th, 2009 @ 07:39 AM
I can't launch script/server anymore in a default rails app with edge
/Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:163:in `ensure_session_key': A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb (ArgumentError) from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:74:in `initialize' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:72:in `new' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:72:in `build' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:110:in `build' from /Users/Thibaud/Desktop/test2/vendor/rails/activesupport/lib/active_support/inflector.rb:359:in `inject' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:110:in `each' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:110:in `inject' from /Users/Thibaud/Desktop/test2/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:110:in `build' ... 12 levels... from /Users/Thibaud/Desktop/test2/vendor/rails/railties/lib/commands/server.rb:84 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from ./script/server:3
-
Eloy Duran February 20th, 2009 @ 09:16 AM
Same problem as Thibaud overhere.
I haven't had the time to investigate, no time so had to revert, but at least it seems there wasn't and isn't enough test coverage for this area, because the tests still run fine.
-
Flurin February 20th, 2009 @ 11:07 AM
We've encountered the same problem here. Josh tried to fix the problem by letting the MiddlewareStack decide wether or not to load the SessionStore based on wether or not it's available.
It seems however that because of a default SessionStore (CookieStore) it tries to load that but it hasn't any options set yet. (Because the middlewarestack is initialized before any rails initializers are run).
-
josh February 20th, 2009 @ 04:24 PM
- State changed from resolved to open
-
Sven Fuchs February 20th, 2009 @ 04:25 PM
- State changed from open to resolved
I've created a new ticket for this and added a patch: #2028
-
josh February 20th, 2009 @ 04:27 PM
- State changed from resolved to open
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Tags
Referenced by
- 2001 Rails 2.3 does not obey config.action_controller.session_store (from [9702636a08e50e9fed9bf76ad620a6a0a109009e]) Lazy ev...
- 2022 Js.erb templates broken in 2.3.0 RC1? Apparently other users have the same issue (see Thibaud's...
- 2028 CookieStore does not get passed config settings Followup to #2001
- 2028 CookieStore does not get passed config settings This fixes the issue mentioned in the comments of #2001 t...