我目前使用的是默认的Cookie作为我(SSO)的单点登录,但有些用户越来越奇怪的错误,我把更新后。我正考虑搬到活动记录到存储会话,但不知道我该怎么告诉轨,该会议是在另一个数据库?
I'm currently using the default cookies as my single sign on (SSO) but some users are getting strange errors after I push an update. I'm considering moving to active record to store sessions but was wondering how I tell rails that the sessions are in another database?
所以,如果我通过AR存储会议在App1DB如何能够在其他应用程序知道多数民众赞成在寻找的会议?
So if I store sessions via AR in App1DB how can all the other apps know thats where to look for sessions?
Rails的肯定确实支持数据库会话存储。
Rails most certainly does support database session storage.
在配置/ environment.rb文件,取消注释
In config/environment.rb, uncomment
# config.action_controller.session_store = :active_record_store
检查\ ActionPack的-2.2.2 \ lib目录\ action_controller \会议\ active_record_store.rb显示,CGI ::会议::为ActiveRecordStore ::会议于的ActiveRecord :: Base的继承。
Examining \actionpack-2.2.2\lib\action_controller\session\active_record_store.rb shows that CGI::Session::ActiveRecordStore::Session inherits from ActiveRecord::Base.
因此,在到config / environment.rb结束时,你应该能够说
So at the end of config/environment.rb, you should be able to say
CGI::Session::ActiveRecordStore::Session.establish_connection(
:adapter => "mysql",
:host => "otherserver",
:username => "session_user",
:password => "123ABC",
:database => "sessions")
或
CGI::Session::ActiveRecordStore::Session.establish_connection(:sessions)
使用Connect在配置/ database.yml中
to use a connect defined in config/database.yml
例如,添加到配置/ database.yml中:
For example, add to config/database.yml:
sessions_development:
adapter: mysql
host: otherserver
username: sessions_user
password: 123ABC
database: sessions
加入到config / environment.rb年底
Add to the end of config/environment.rb
CGI::Session::ActiveRecordStore::Session.establish_connection("sessions_#{RAILS_ENV}")