0

我们正在努力将 ruby​​ 版本从 2.3.1 更新到 3.0.2 和相关更改。我们在上传文件时遇到问题。我刚刚设置了文件上传的形式并设置了上传事件,没有任何模型连接进行测试。事件模型尚未创建或附加任何文件,在提交按钮上,系统引发 TypeError。

作为更新 ruby​​ 和 rails "config.cache_store = :mem_cached_store" 的一部分,我已将 dalli 缓存存储更改为 mem_cache_store

我检查了 cache.rb 并在压缩中发出了 raise!“序列化 = Marshal.dump(@value)”时的方法

还设置 param[:image] = nil rescue nil,所以在重定向之前很清楚,但仍在会话中我找到了图像文件上传条目。这个错误是由于 Marshal.dump 尝试序列化文件上传对象造成的吗?

有没有办法解决这个错误?

错误:

TypeError: can't dump File
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:858:in `dump'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:858:in `compress!'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:792:in `initialize'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:475:in `new'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:475:in `block in write'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:726:in `block in instrument'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:205:in `instrument'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:726:in `instrument'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache.rb:474:in `write'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/session/cache_store.rb:34:in `write_session'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:388:in `commit_session'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:268:in `context'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/cookies.rb:689:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/web-console-2.3.0/lib/web_console/middleware.rb:28:in `block in call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `catch'
from /home/test/.rvm/gems/ruby-3.0.2/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/rack/logger.rb:37:in `call_app'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/rack/logger.rb:26:in `block in call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/tagged_logging.rb:101:in `block in tagged'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/tagged_logging.rb:37:in `tagged'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/tagged_logging.rb:101:in `tagged'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/rack/logger.rb:26:in `call'
from /media/test/DATA1/user/sampleproject/lib/custom_logger.rb:17:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/request_store-1.5.0/lib/request_store/middleware.rb:19:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/request_id.rb:26:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/static.rb:24:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-mini-profiler-2.3.3/lib/mini_profiler/profiler.rb:393:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/engine.rb:539:in `call'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
from /home/test/.rvm/gems/ruby-3.0.2/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
from /home/test/.rvm/gems/ruby-3.0.2/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
from /home/test/.rvm/gems/ruby-3.0.2/gems/webrick-1.7.0/lib/webrick/httpserver.rb:140:in `service'
from /home/test/.rvm/gems/ruby-3.0.2/gems/webrick-1.7.0/lib/webrick/httpserver.rb:96:in `run'
from /home/test/.rvm/gems/ruby-3.0.2/gems/webrick-1.7.0/lib/webrick/server.rb:310:in `block in start_thread

样本测试文件:

<%= form_with :url => uploads_project_path(@project), :method => :post, multipart: true, :remote => true do |f| %>
  <div>
    <%= f.label :title %>
    <%= f.text_field :title %>
  </div>
  <div>
    <%= f.label :image %>
    <%= f.file_field :image %>
  </div>
  <%= f.submit %>
<% end %>
4

0 回答 0