views:

29

answers:

1

Hi -

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.

+1  A: 

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?

Shtééf
yup, `ActiveRecord::SessionStore::Session.establish_connection :sessions` in config/initializers/session_store.rb did the job...
sa125