0

试图调试一个令人困惑的问题。从 Rails 3.22.xx -> 4.2.11.3 升级旧应用程序。

如果我运行rails s服务器启动并且应用程序加载就好了。

=> Booting Puma
=> Rails 4.2.11.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[20409] Puma starting in cluster mode...
[20409] * Puma version: 5.5.2 (ruby 2.4.0-p0) ("Zawgyi")
[20409] *  Min threads: 8
[20409] *  Max threads: 32
[20409] *  Environment: development
[20409] *   Master PID: 20409
[20409] *      Workers: 2
[20409] *     Restarts: (✔) hot (✖) phased
[20409] * Preloading application
[20409] * Listening on http://127.0.0.1:3000
[20409] * Listening on http://[::1]:3000
[20409] Use Ctrl-C to stop

但是,如果我使用为 puma-dev 设置的域,则会出错。该错误与 mongo gem 和 BSON 序列化有关。

下面的代码value只是我从 mongo gem 中注销的内容。

appName[28214]: bash: no job control in this shell
appName[28214]: Puma starting in single mode...
appName[28214]: * Puma version: 5.5.2 (ruby 2.4.0-p0) ("Zawgyi")
appName[28214]: *  Min threads: 0
appName[28214]: *  Max threads: 5
appName[28214]: *  Environment: development
appName[28214]: *          PID: 28214
appName[28214]: VALUE : {:ping=>1}
appName[28214]: VALUE : 
appName[28214]: VALUE : {:ping=>1, "$db"=>"admin"}
appName[28214]: VALUE : {:ismaster=>1}
appName[28214]: VALUE : 
appName[28214]: VALUE : {:ismaster=>1, "$db"=>"admin"}
appName[28214]: * Listening on unix:/Users/rockwellrice/.puma-dev/appName/tmp/puma-dev-431.sock
appName[28214]: Use Ctrl-C to stop
! App 'appName' booted
appName[28214]: VALUE : {:ismaster=>1, :compression=>[], :client=>{"driver"=>{"name"=>"mongo-ruby-driver", "version"=>"2.7.0"}, "os"=>{"type"=>"darwin", "name"=>"darwin18.7.0", "architecture"=>"x86_64"}, "platform"=>"mongoid-5.4.1, 2.4.0, x86_64-darwin18, x86_64-apple-darwin18.7.0"}}
appName[28214]: VALUE : 
appName[28214]: VALUE : {"find"=>"users", "filter"=>{"_id"=>"93221de412af253e53231735"}, "limit"=>1, "singleBatch"=>true, "$db"=>"reader", "lsid"=>{"id"=><BSON::Binary:0x70235818644900 type=uuid data=0x4730a5f638de4dce...>}}

该错误具体发生在它获取用户 ID 值并返回时

BSON::Error::UnserializableClass 
Value does not define its BSON serialized type: 93221de412af253e53231735

我很困惑为什么在通过 puma dev 加载时会发生这种情况,但在使用 Rails 并转到 localhost:3000 时不会发生这种情况。

Ruby on rails 4.2.11.3、Mongo 2.7.0、MongoID 5.4.1。

4

0 回答 0