Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 4中的Cookie溢出,即使使用memcachd服务器_Ruby On Rails_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails Rails 4中的Cookie溢出,即使使用memcachd服务器

Ruby on rails Rails 4中的Cookie溢出,即使使用memcachd服务器,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,我正在将一个Rails 3应用程序转换为Rails 4,该应用程序使用active\u record\u store来存储会话信息,该信息对于常规cookie来说太大了。Rails 4已经弃用了active\u record\u store。我的Rails 4应用程序正在引发错误 ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow): 这导致我在Rails 3中切换到活动记录存储。如果

我正在将一个Rails 3应用程序转换为Rails 4,该应用程序使用
active\u record\u store
来存储会话信息,该信息对于常规cookie来说太大了。Rails 4已经弃用了active\u record\u store。我的Rails 4应用程序正在引发错误

ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
这导致我在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"]

如果使用cookie存储,则只能在会话中存储4kb。你有两个选择

  • 查看如何减少会话中存储的信息。如果要在会话中存储模型对象,请将其更改为仅存储id

  • 使用内存缓存存储

    config.action\u controller.session\u store=:mem\u cache\u store

  • 此外,您还需要设置mem缓存服务器,并按照以下方式进行配置:

    config.cache_store = :mem_cache_store, 'localhost', '127.0.0.1:11211',
    {:namespace => 'myapp123'}
    

    你能给我看看config/initializers/session_store.rb的内容吗?看起来你还在使用那里的cookie存储

    定义缓存存储时,仍然需要更改会话存储

    config.session_store = :mem_cache_store
    

    尽管我已经启动了一个mem缓存服务器并按照您的建议进行了配置,但我还是遇到了相同的错误。我将在OP的更新中发布错误。它似乎仍然使用cookies存储。。。config/initializers/session_store.rb文件中有什么
    config.session_store = :mem_cache_store