我正在将 rails 4.2 站点升级到 6.0 并收到
uninitialized constant Authlogic::Session::Validation
当我尝试加载表单时,大概是因为 Validation 模块已从 Authlogic 中删除,并且一些旧的 gem/code 仍在尝试引用它。如果我对 form_with 使用authentity_token=false 选项,它就会消失,但显然我不想这样做。
所以,在某个地方,某种东西正在引用这个旧模块。这是摩擦:
- 我已经在整个代码库中搜索“Authlogic::Session::Validation”。没有什么。
- 我已经在整个 gem 树中搜索“Authlogic::Session::Validation”。没有什么。
就像它被配置为用于生成表单真实性令牌或其他东西的插件,但我不知道该配置在哪里或如何找到它。我的意思是,对于那个错误,那个字符串必须在某个地方,对吧?
这是我收到错误时调用堆栈的相关部分(我的代码在moments.haml中):
Application Trace | Framework Trace | Full Trace
activesupport (6.0.2.2) lib/active_support/inflector/methods.rb:284:in `const_get'
activesupport (6.0.2.2) lib/active_support/inflector/methods.rb:284:in `block in constantize'
activesupport (6.0.2.2) lib/active_support/inflector/methods.rb:280:in `each'
activesupport (6.0.2.2) lib/active_support/inflector/methods.rb:280:in `inject'
activesupport (6.0.2.2) lib/active_support/inflector/methods.rb:280:in `constantize'
activesupport (6.0.2.2) lib/active_support/core_ext/string/inflections.rb:68:in `constantize'
activesupport (6.0.2.2) lib/active_support/core_ext/marshal.rb:10:in `rescue in load'
activesupport (6.0.2.2) lib/active_support/core_ext/marshal.rb:5:in `load'
activerecord-session_store (1.1.3) lib/active_record/session_store.rb:63:in `load'
activerecord-session_store (1.1.3) lib/active_record/session_store.rb:20:in `deserialize'
activerecord-session_store (1.1.3) lib/active_record/session_store/session.rb:71:in `data'
activerecord-session_store (1.1.3) lib/action_dispatch/session/active_record_store.rb:141:in `find_session'
rack (2.2.2) lib/rack/session/abstract/id.rb:314:in `load_session'
actionpack (6.0.2.2) lib/action_dispatch/middleware/session/abstract_store.rb:46:in `block in load_session'
actionpack (6.0.2.2) lib/action_dispatch/middleware/session/abstract_store.rb:54:in `stale_session_check!'
actionpack (6.0.2.2) lib/action_dispatch/middleware/session/abstract_store.rb:46:in `load_session'
actionpack (6.0.2.2) lib/action_dispatch/request/session.rb:235:in `load!'
actionpack (6.0.2.2) lib/action_dispatch/request/session.rb:231:in `load_for_write!'
actionpack (6.0.2.2) lib/action_dispatch/request/session.rb:132:in `[]='
actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:397:in `real_csrf_token'
actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:327:in `masked_authenticity_token'
actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:314:in `form_authenticity_token'
actionpack (6.0.2.2) lib/abstract_controller/helpers.rb:67:in `form_authenticity_token'
actionview (6.0.2.2) lib/action_view/helpers/url_helper.rb:622:in `token_tag'
actionview (6.0.2.2) lib/action_view/helpers/form_tag_helper.rb:863:in `extra_tags_for_form'
actionview (6.0.2.2) lib/action_view/helpers/form_tag_helper.rb:883:in `form_tag_html'
actionview (6.0.2.2) lib/action_view/helpers/form_tag_helper.rb:888:in `form_tag_with_body'
actionview (6.0.2.2) lib/action_view/helpers/form_helper.rb:759:in `form_with'
app/views/layouts/moments.haml:264
编辑:我在调用 form_authenticity_token (在上面的调用堆栈中引用)时设置 csrf-token 元标记时遇到了同样的错误。我忘记了我在尝试调试时已将其注释掉。