mongoid

Rails: Wrong number of arguments (given 2, expected 1) MongoID

我们两清 提交于 2020-03-23 12:02:02
问题 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 My Mongo credentials are correct, and I can connect to the database's collections outside of Rails. The first few lines of the error are: 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

Rails: Wrong number of arguments (given 2, expected 1) MongoID

蓝咒 提交于 2020-03-23 12:01:50
问题 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 My Mongo credentials are correct, and I can connect to the database's collections outside of Rails. The first few lines of the error are: 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

MongoDB creates parent objects when I try to create child objects

馋奶兔 提交于 2020-02-07 17:15:53
问题 This model: class SimCustomer < Customer index({ user_id: 1 }, { background: true }) belongs_to :user, :inverse_of => :sim_customers end inherits from this model: class Customer include Mongoid::Document include Mongoid::Timestamps field :mail_address, type: String end I create the indexes from my terminal: bundle exec rake db:mongoid:create_indexes But this creates indexes on the Customer instead of the SimCustomer : I, [2014-11-13T16:21:17.210343 #11407] INFO -- : MONGOID: Created indexes

MongoDB creates parent objects when I try to create child objects

爷,独闯天下 提交于 2020-02-07 17:14:03
问题 This model: class SimCustomer < Customer index({ user_id: 1 }, { background: true }) belongs_to :user, :inverse_of => :sim_customers end inherits from this model: class Customer include Mongoid::Document include Mongoid::Timestamps field :mail_address, type: String end I create the indexes from my terminal: bundle exec rake db:mongoid:create_indexes But this creates indexes on the Customer instead of the SimCustomer : I, [2014-11-13T16:21:17.210343 #11407] INFO -- : MONGOID: Created indexes

Field aliases with Mongoid and Rails

风格不统一 提交于 2020-01-21 03:16:13
问题 It's common practice in MongoDB to use short key names to save space. For example, one might want to use "fn" instead of "first_name" However in your app, you're screwed if you use "fn" all over the place. It's too ugly. For Rails specifically, is there an easy way to specify an alias when declaring a field in Mongoid? Also, does anyone know of any open source sample projects that use Mongoid? Thanks! 回答1: you should consider using field :fn, :as => :firstname as outlined here: http://groups

How can I query mongodb using mongoid/rails without timing out?

送分小仙女□ 提交于 2020-01-20 05:17:04
问题 I have a rake task that processes a set of records and saves it in another collection: batch = [] Record.where(:type => 'a').each do |r| batch << make_score(r) if batch.size %100 == 0 Score.collection.insert(batch) batch = [] end end I'm processing about 100K records at a time. Unfortunately at 20 minutes, I get a Query response returned CURSOR_NOT_FOUND error. The mongodb faq says to use skip and limit or turn off timeouts, using them the all thing was about ~2-3 times slower. How can I turn