ruby-on-rails - Rails:参数数量错误(给定2个,预期为1个)MongoID

标签 ruby-on-rails mongodb mongoid rails-admin

我正在尝试打开MongoDB模型,但是,出现以下错误:
MONGODB | xxx.xx.x.xxx:27017 | db.find | FAILED | wrong number of arguments (given 2, expected 1) | 0.013306s
我的Mongo凭据是正确的,我可以在Rails之外连接到数据库的集合。

错误的前几行是:

Started GET "/admin/xsl_sheet" for xxx.xxx.xxx.xxx at 2020-03-03 13:49:54 UTC
Processing by RailsAdmin::MainController#index as HTML
Parameters: {"model_name"=>"xsl_sheet"}
(5.0ms)  SELECT `companies`.`name` FROM `companies` WHERE `companies`.`id` = 4
CACHE (0.1ms)  SELECT `companies`.`name` FROM `companies` WHERE `companies`.`id` = 4  [["id", "4"]]
CACHE (0.2ms)  SELECT `companies`.`name` FROM `companies` WHERE `companies`.`id` = 4  [["id", "4"]]

MONGODB | xxx.xx.x.xxx:27017 | db.saslStart | STARTED | {}
MONGODB | xxx.xx.x.xxx:27017 | db.saslStart | SUCCEEDED | 0.007s
MONGODB | xxx.xx.x.xxx:27017 | db.saslContinue | STARTED | {}
MONGODB | xxx.xx.x.xxx:27017 | db.saslContinue | SUCCEEDED | 0.006s
MONGODB | xxx.xx.x.xxx:27017 | db.saslContinue | STARTED | {}
MONGODB | xxx.xx.x.xxx:27017 | db.saslContinue | SUCCEEDED | 0.006s
MONGODB | xxx.xx.x.xxx:27017 | db.find | STARTED | {"find"=>"TestCompanyNumber2_xsl_sheets", "filter"=>{"assetable_id"=>4}, "limit"=>1, "skip"=>0, "sort"=>{"_id"=>-1}, "projection"=>{"_id"=>1}}
MONGODB | xxx.xx.x.xxx:27017 | db.find | FAILED | wrong number of arguments (given 2, expected 1) | 0.013306s
Rendered /Project/app/views/rails_admin/main/index.html.haml within 
    layouts/rails_admin/application (349.7ms)
    Rendered public/500.html (64.4ms)
    wrong number of arguments (given 2, expected 1)
    /GEMS/gems/bson-4.8.0-java/lib/bson/hash.rb:115:in `from_bson'

编辑:

这是rails_admin.rb中的代码(我相信)负责从MongoDB中提取对象:
c.model XslSheet do
  label Proc.new {"Xsl Sheet"}
  navigation_label Proc.new {I18n.t('navigation.actions')}
  weight 303
  navigation_icon 'fa fa-file-excel-o'
  list do
    scopes [:applicationId]
    field :data_file_name
    field :updated_at
  end
end

最佳答案

这是https://jira.mongodb.org/browse/RUBY-2146。降级到bson 4.7.0,直到发布4.8.2。

为了帮助人们回答您的问题,请包括您正在使用的软件版本(在这种情况下,mongoidmongobson版本是相关的),以及您正在使用JRuby的事实。

关于ruby-on-rails - Rails:参数数量错误(给定2个,预期为1个)MongoID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60528052/

相关文章:

ruby-on-rails - Rails 遍历深度哈希数组

mongodb - Z 在 MongoDB 日期格式中的含义

c# - 整数上的 Mongo C# 过滤器包含

ruby-on-rails-3 - Rails/ActiveModel 将参数传递给 EachValidator

ruby-on-rails - 使用 mongoid gem 时延迟加载 has_and_belongs_to_many 字段

ruby-on-rails - 更改 bundle 安装 Ruby 版本

ruby-on-rails - Griddler 配置未定义的方法 processor_class

ruby - 使用 mongodb/mongoid 运行时更改模型

ruby-on-rails - 无法使用 .to_i 将数组中的第一个元素转换为整数

mongodb - Playframework 2.3x : scala. concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent]