2010-04-30 41 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) 

讓我知道,如果工作。