2010-04-30 67 views
0

我试图通过改变 的config/application.rb中如下切换在Rails 3的会话存储:无法获取会话选项?

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的新手。

任何帮助将不胜感激。

感谢

回答

0

我不-entirely-肯定,但我认为你需要包括“cached_model。”尝试加入

require 'cached_model' #(At the top) 

让我知道,如果工作。