我正在将 Rails 3 应用程序转换为 Rails 4 应用程序,该应用程序active_record_store
用于存储对于常规 cookie 来说太大的会话信息,该应用程序已弃用 active_record_store。我的 Rails 4 应用程序正在引发错误...
ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
这导致我切换到active_record_store
Rails 3。如果我的会话信息超过允许的限制,我可以在 Rails 4 中做什么?
更新。我在本地机器上启动了 memcache 服务器,并在开发文件中这样配置它
config.cache_store = :mem_cache_store, 'localhost', '127.0.0.1:11211',
{:namespace => 'myapp123'}
在控制台中,当我执行 Rails.cache 时,它显示了这一点(后面跟着很多数据)
=> 真
>> Rails.cache
=> #<ActiveSupport::Cache::MemCacheStore:0x007f80ebe10500 @options={}, @data=#<Dalli::Client:0x007f80ebe0fd08 @servers=["localhost:11211"]
但是,当我运行应用程序时,我遇到了同样的错误
ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/cookies.rb:455:in `[]='
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/session/cookie_store.rb:109:in `set_cookie'
rack (1.5.2) lib/rack/session/abstract/id.rb:350:in `commit_session'
rack (1.5.2) lib/rack/session/abstract/id.rb:226:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0.rc2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0.rc2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0.rc2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:373:in `_run__1963944942928963409__call__callbacks'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0.rc2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0.rc2) lib/rails/engine.rb:511:in `call'
railties (4.0.0.rc2) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/mm/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/mm/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/mm/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'