我有一个Sinatra应用程序,我想使用命名空间使其更干净。我安装了sinatra-contrib
gem并添加了require 'sinatra/namespace'
。当我使用puma config.ru
运行应用时,我不断收到以下错误:
Puma starting in single mode...
* Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
* Min threads: 0, max threads: 16
* Environment: development
/usr/local/lib/ruby/gems/2.4.0/gems/backports-3.6.0/lib/backports/1.8.7/fixnum/div.rb:1: warning: constant ::Fixnum is deprecated
/usr/local/lib/ruby/gems/2.4.0/gems/backports-3.6.0/lib/backports/1.8.7/fixnum/fdiv.rb:1: warning: constant ::Fixnum is deprecated
! Unable to load application: Errno::EBADF: Bad file descriptor @ fptr_finalize_flush - /usr/local/lib/ruby/gems/2.4.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb
/usr/local/lib/ruby/gems/2.4.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb:2:in `close': Bad file descriptor @ fptr_finalize_flush - /usr/local/lib/ruby/gems/2.4.0/gems/backports-3.6.0/lib/backports/1.9.1/io/open.rb (Errno::EBADF)
以下是我的代码:
require 'sinatra'
require 'sinatra/namespace'
namespace '/v1/picking' do
post '/tasks/:task_id/barcodes/create' do
barcode_content = JSON.parse(request.body.read)
# DO SOME STUFF
return 'OK'
end
end
我正在使用Ruby 2.4.1和Sinatra 2.0.0。
我做错了什么?
答案 0 :(得分:0)
由于一些错误,Backports 3.6.0被破坏了。官方称这是固定的。我查了3.8.0,效果很好。升级您的宝石。