Rails 2.3 - Storing sessions in different schema
I want to configure my app to use a different schema than the default for storing sessions. Basically, I want the app to store all its active_record objects in app_development and only its sessions in app_sessions. Normally this could be done by defining the sessions db in database.yml:
development:
# ...
sessions:
host: localhost
database: app_sessions
username: blah
password: sssshhh
开发者_开发知识库 #....
And then setting in the model:
class Session < ActiveRecord::Base
establish_connection :sessions
#...
end
But since session doesn't have a model class defined, I'm looking for a way to tell it where to store its data. I've noticed the session comes from ActionController::Session
, but couldn't find what I needed there. Any thoughts? thanks.
There actually is a model. It's called ActiveRecord::SessionStore::Session
.
I haven't tried, but perhaps you can use an initializer to re-open this class, and call establish_connection
on it?
精彩评论