【问题标题】:Rails Puma Server: Undefined `extract_multipart' or `before_create' on logout actionRails Puma Server:注销操作时未定义“extract_multipart”或“before_create”
【发布时间】:2017-01-29 22:00:05
【问题描述】:

我无法退出自己的页面,因为每次尝试都会收到undefined method Puma 错误。大多数时候是extract_multipart,但我也见过before_create

当我单击注销时,这就是空白页面中显示的内容

Puma caught this error: undefined method `extract_multipart' for Rack::Multipart:Module (NoMethodError)
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:472:in `parse_multipart'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:335:in `POST'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/method_override.rb:39:in `method_override_param'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/method_override.rb:27:in `method_override'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/method_override.rb:15:in `call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'
/var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/var/lib/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call'
/var/lib/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/static.rb:136:in `call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'
/var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/engine.rb:522:in `call'
/var/lib/gems/2.3.0/gems/puma-3.6.2/lib/puma/configuration.rb:225:in `call'
/var/lib/gems/2.3.0/gems/puma-3.6.2/lib/puma/server.rb:578:in `handle_request'
/var/lib/gems/2.3.0/gems/puma-3.6.2/lib/puma/server.rb:415:in `process_client'
/var/lib/gems/2.3.0/gems/puma-3.6.2/lib/puma/server.rb:275:in `block in run'
/var/lib/gems/2.3.0/gems/puma-3.6.2/lib/puma/thread_pool.rb:116:in `block in spawn_thread'

我管理注销的方式是使用

<%= link_to(logout_path, method: 'delete', class: 'dropdown-item') do %>
<!-- ... -->
<% end %>

其中路由定义为delete 'logout' =&gt; 'sessions#destroy',控制器/动作为

def destroy
  session[:id] = nil
  redirect_to '/login'
end

另一个我只发现一两次的错误,我只有一个截图

Puma: undefined before_create

关于可能导致此问题的任何想法?提前感谢:)

编辑

根据要求,这里是 Enumerable 关注点,我实际上并没有使用它,因为我也遇到了这个问题(在 auto-inc 存储库上提交的 GH 问题)

require 'autoinc'

module Enumerable
  extend ActiveSupport::Concern

  included do
    include Mongoid::Autoinc
    include Mongoid::Document

    field :n, as: :number, type: Integer

    increments :number
  end
end

而我使用的唯一before_create 在一个完全不相关的模块中...

编辑 2

尝试将 puma 更新为 3.7.0,但没有解决。虽然它并没有进一步打破它......

【问题讨论】:

  • 能否请您添加可枚举的关注点以及您使用before_create 回调的位置?
  • 完成,尽管正如我所说,before_create 使用的模型与用户/会话无关

标签: ruby-on-rails ruby-on-rails-5 puma mongoid6


【解决方案1】:

答案来自

Delete link sends "Get" instead of "Delete" in Rails 3 view

我需要将&lt;%= csrf_meta_tag %&gt; 添加到我的head

【讨论】:

    猜你喜欢
    • 2014-02-08
    • 2017-11-07
    • 1970-01-01
    • 2016-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多