无法获得会话选项?

时间:2010-04-30 18:09:44

标签: ruby-on-rails session

我正在尝试通过更改来切换Rails 3中的会话存储 config / application.rb如下:

config/application.rb 
#----------------------------------- 
memcache_options = { 
  :compression => true, 
  :debug => false, 
  :namespace => "xx-cache", 
  :readonly => false, 
  :urlencode => false 
} 
CACHE = MemCache.new(memcache_options) 
CACHE.servers = ['127.0.0.1:17898'] 
#check if CACHE is connected 
#puts CACHE 
config.action_dispatch.session = { 
  :session_key => '_xx_session', 
  :secret => 'xx', 
  :cache => CACHE, 
  :expires => 900 
} 
config.action_dispatch.session_store = :mem_cache_store 
#----------------------------------- 

Memcache服务器正在运行。但是,当运行rails s时,我得到了这个 消息:

=> Booting WEBrick 
=> Rails 3.0.0.beta3 application starting in development on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
Exiting 
/usr/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0.beta3/lib/ 
action_dispatch/middleware/session/mem_cache_store.rb:19:in 
`initialize': #<ActionDispatch::Session::MemCacheStore:0xa302950> 
unable to find server during initialization. (RuntimeError)

似乎会话选项未正确传递。但我不是 确定这里有什么问题因为我是Rails的新手。

任何帮助将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

我不是 - 但我觉得你需要包含“cached_model”。尝试添加

require 'cached_model' #(At the top)

如果有效,请告诉我。