This project is archived and is in readonly mode.
Edge rails sessions not getting stored to database
Reported by Nate Wiger | February 13th, 2009 @ 02:50 AM
Hi Josh, I have assigned this to you based on a comment in this commit:
http://github.com/rails/rails/co...
Currently, running our app on Edge Rails (2.3.x) with SqlSessionStore is resulting in no sessions being stored to the database. We activate SqlSessionStore in environment.rb:
config.action_controller.session_store = :sql_session_store
However, this code does not appear to be working. I just jammed a whole bunch of "raise 'death'" calls into sql_session_store and they are never triggered.
Comments and changes to this ticket
-
josh February 13th, 2009 @ 02:58 AM
- Milestone cleared.
I think the plugin may have to be updated to work with Rack. It still may be based on the CGI stuff.
-
Nate Wiger February 13th, 2009 @ 03:06 AM
Josh, thanks for the quick reply. I have a git fork of it, as I suspected as much. Any pointers so I can make the changes? That way I can push it so when 2.3 comes out SqlSessionStore will be compatible.
My fork is at:
-
josh February 13th, 2009 @ 04:57 AM
If you inherit from ActionController::Session::AbstractStore, you just need to supply 2 methods: get_session and set_session.
See the AR session store for a good example.
http://github.com/josh/rails/blo...
After that should session store "should" be compatible with any rack application, merb, sinatra, etc.
-
Nate Wiger February 14th, 2009 @ 01:26 AM
Thanks for the pointer, but Josh, I'm stumped. I tried following that class and rewrote SqlSessionStore as follows:
class SqlSessionStore < ActionController::Session::AbstractStore
cattr_accessor :session_class self.session_class = SqlSession class << self # Rack-ism for Rails 2.3.0 SESSION_RECORD_KEY = 'rack.session.record'.freeze # For Rack compatibility (Rails 2.3.0+) def get_session(env, sid) sid ||= generate_sid session = session_class.find_session(sid) env[SESSION_RECORD_KEY] = session [sid, session.data] end # For Rack compatibility (Rails 2.3.0+) def set_session(env, sid, session_data) session = env[SESSION_RECORD_KEY] session.update_session(session_data) end end
end
Then in config/environment.rb:
config.action_controller.session_store = :sql_session_store SqlSessionStore.session_class = OracleSession
No worky.
What am I missing?
-
Nate Wiger February 14th, 2009 @ 06:27 AM
FYI I pushed my (unstable) Rack session mods to my git fork:
git://github.com/nateware/sql_session_store.git
-
Nate Wiger February 14th, 2009 @ 04:14 PM
By the way, the oddity is that I would think setting:
config.action_controller.session_store = :sql_session_store SqlSessionStore.session_class = OracleSession
Should, if the SqlSessionStore class is not implemented correctly, raise an error like:
Undefined method 'get_session' for #<SqlSessionStore:Class>
But that doesn't happen. In fact it seems like SqlSessionStore is never called by the session store callbacks??
-
josh February 15th, 2009 @ 12:29 AM
get_session and set_session should be instance methods, not class methods. You can also delete all the CGI api methods, they are unless now. So close, delete, restore, etc can be removed.
-
josh February 16th, 2009 @ 08:23 PM
- State changed from new to invalid
Hey, just ping me at josh at joshpeek dot com if you need anymore help porting the thing over to rack.
(Closing because the plugin needs to be updated)
-
csnk May 18th, 2011 @ 08:18 AM
We are the professional shirts manufacturer, shirts supplier, shirts factory, custom shirts.
-
csnk May 18th, 2011 @ 08:18 AM
We are the professional shirts manufacturer, shirts supplier, shirts factory, custom shirts.
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>