Ruby on rails 获取会话选项失败?
我试图通过更改 config/application.rb如下所示:Ruby on rails 获取会话选项失败?,ruby-on-rails,session,Ruby On Rails,Session,我试图通过更改 config/application.rb如下所示: config/application.rb #----------------------------------- memcache_options = { :compression => true, :debug => false, :namespace => "xx-cache", :readonly => false, :urlencode => fals
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新手
任何帮助都将不胜感激
谢谢我不完全确定,但我认为您需要包括缓存的\u模型。尝试添加
require 'cached_model' #(At the top)
让我知道这是否有效