Rails:参数数量错误(给定2个,预期为1个)MongoID [英] Rails: Wrong number of arguments (given 2, expected 1) MongoID

查看:159
本文介绍了Rails:参数数量错误(给定2个,预期为1个)MongoID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打开MongoDB模型,但是,出现以下错误:

I'm trying to open my MongoDB models, however, I'm getting the following error:

MONGODB | xxx.xx.x.xxx:27017 | db.find | FAILED | wrong number of arguments (given 2, expected 1) | 0.013306s

我的Mongo凭据是正确的,我可以在Rails外部连接到数据库的集合.

My Mongo credentials are correct, and I can connect to the database's collections outside of 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中提取对象:

Here is the code inside rails_admin.rb which (I believe) is in charge of pulling objects from 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.

This is https://jira.mongodb.org/browse/RUBY-2146. Downgrade to bson 4.7.0 until 4.8.2 is released.

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

To help people answer your questions, include the versions of the software you are using (in this case, mongoid, mongo and bson versions are relevant), as well as the fact you are using JRuby.

这篇关于Rails:参数数量错误(给定2个,预期为1个)MongoID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆