ruby-on-rails-3 – 导致“ArgumentError(转储格式错误)”的原因是什么?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-3 – 导致“ArgumentError(转储格式错误)”的原因是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_0@
在Spree中对产品列表没有分页并且仅列出前10个产品的错误行为进行故障排除时,我尝试在本地开发环境中重现错误,并在第一页加载时收到错误
ArgumentError (dump format error)

和往常一样,我先检查了我的另一个脑子.最热门的搜索结果是:https://github.com/rails/rails/issues/2509

虽然启动该线程的用户和其他几个海报尝试从Rails 3.0.9升级到Rails 3.1,但我认为它不适用于我的情况.我正在运行的Spree 0.60.2应用程序是在Rails 3.0.9.

然而,事实证明,只需清除我的localhost cookie即可解决问题.为什么?

解决方法

我将推测,因为我在我的开发环境中运行多个应用程序,包括相同应用程序的Rails 3.1 / Spree 0.70版本,并且我通过localhost访问所有这些应用程序,所以存在某种冲突cookie,3.1版本设置一些3.0.9版本不能吃的cookie.这可能与@Fjan在他的帖子中提到的( https://github.com/rails/rails/issues/2509)有关:

I traced this error and it happens because the FlashHash class in the
session has been changed to no longer inherit from the Hash class in
rails 3.1.

我做了一个实验.如果我没有登录任何一个版本的应用程序,我可以启动一个并关闭它并启动另一个并且不会遇到这个问题.但是,当我登录到3.0.9版本然后关闭该服务器并启动3.1版本时,我再次收到相同的错误.这是部分跟踪:

activesupport (3.1.1) lib/active_support/message_verifier.rb:34:in
load' activesupport (3.1.1)
lib/active_support/message_verifier.rb:34:in
verify’ actionpack
(3.1.1) lib/action_dispatch/middleware/cookies.rb:280:in []'
actionpack (3.1.1)
lib/action_dispatch/middleware/session/cookie_store.rb:53:in
block in
unpacked_cookie_data’ actionpack (3.1.1)
lib/action_dispatch/middleware/session/abstract_store.rb:55:in
stale_session_check!' actionpack (3.1.1)
lib/action_dispatch/middleware/session/cookie_store.rb:51:in
unpacked_cookie_data’ rack (1.3.6) lib/rack/session/cookie.rb:96:in
extract_session_id' actionpack (3.1.1)
lib/action_dispatch/middleware/session/abstract_store.rb:51:in
block
in extract_session_id’ actionpack (3.1.1)
lib/action_dispatch/middleware/session/abstract_store.rb:55:in
stale_session_check!' actionpack (3.1.1)
lib/action_dispatch/middleware/session/abstract_store.rb:51:in
extract_session_id’ rack (1.3.6)
lib/rack/session/abstract/id.rb:43:in load_session_id!' rack (1.3.6)
lib/rack/session/abstract/id.rb:32:in
[]’ rack (1.3.6)
lib/rack/session/abstract/id.rb:252:in current_session_id' rack
(1.3.6) lib/rack/session/abstract/id.rb:258:in
session_exists?’ rack
(1.3.6) lib/rack/session/abstract/id.rb:104:in exists?' rack (1.3.6)
lib/rack/session/abstract/id.rb:114:in
load_for_read!’ rack (1.3.6)
lib/rack/session/abstract/id.rb:64:in has_key?' actionpack (3.1.1)
lib/action_dispatch/middleware/flash.rb:260:in
ensure in call’
actionpack (3.1.1) lib/action_dispatch/middleware/flash.rb:261:in
call' rack (1.3.6) lib/rack/session/abstract/id.rb:195:incontext’
rack (1.3.6) lib/rack/session/abstract/id.rb:190:in `call’

反过来也是如此.当我登录3.1版本然后关闭该服务器并启动3.0.9版本时,我收到了同样的错误.这是部分跟踪:

activesupport (3.0.9) lib/active_support/message_verifier.rb:34:in
load' activesupport (3.0.9)
lib/active_support/message_verifier.rb:34:in
verify’ actionpack
(3.0.9) lib/action_dispatch/middleware/cookies.rb:253:in []'
actionpack (3.0.9)
lib/action_dispatch/middleware/session/cookie_store.rb:68:in
block in
unpacked_cookie_data’ actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:223:in
stale_session_check!' actionpack (3.0.9)
lib/action_dispatch/middleware/session/cookie_store.rb:66:in
unpacked_cookie_data’ actionpack (3.0.9)
lib/action_dispatch/middleware/session/cookie_store.rb:57:in
extract_session_id' actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:39:in
load_session_id!’ actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:27:in []'
actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:210:in
current_session_id’ actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:239:in
exists?' actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:96:in
exists?’ actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:113:in
load_for_read!' actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:53:in
[]’
actionpack (3.0.9) lib/action_dispatch/middleware/flash.rb:178:in
call' actionpack (3.0.9)
lib/action_dispatch/middleware/session/abstract_store.rb:149:in
call’

对我来说值得注意的是,你不需要真正地进行升级.要重现此问题,您只需要运行两个版本的Rails,这两个版本的Rails设置具有相同名称的Cookie …可能是按顺序(如在我的实验中)或同时(我没有尝试过).

希望这里的其他人能提供比这更好的答案,以添加这个松散的解释所缺乏的细节.与此同时,如果你在开发过程中遇到这个问题并且你不关心内部工作,只需清除你的cookie(如上面引用的线程中的@tscolari所建议的那样:https://github.com/rails/rails/issues/2509)并继续前进.干杯.

猜你在找的Ruby相关文章