Questions tagged [mongoid5]

Mongoid 5 is major version 5 of Mongoid, an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.

About

Mongoid is an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.

Links

30 questions
6
votes
1 answer

Rails/Mongoid relationship question with Struct

I have this library app I'm building and it has 3 classes. State, Library, and Book. The State has many libraries and Library belongs_to a State. The Library has many Books, and book is embedded in a library. However, when I make this auto_pick_job…
jmoon90
  • 339
  • 4
  • 17
6
votes
0 answers

Excessive "Server description" changes being logged

I have a replica set running 3.4, which is used by a Rails (4.2.7) application with Mongoid5 (5.1.6) We're getting excessive "Server description has changed" posts to our logging system that don't indicate a change at all (see below.) The platform…
JustMark
  • 65
  • 5
4
votes
0 answers

Sporadic NoServerAvailable errors from mongoid

On production we get a steady stream of seemingly random Mongo::Error::NoServerAvailable errors. Maybe 3 a day. The replica set in question has not experienced any elections, and there is nothing unusual about its performance during these…
cailinanne
  • 8,332
  • 5
  • 41
  • 49
3
votes
0 answers

what is the correct way to connect mongoid dynamically?

I am using mongoid orm and trying to establish connection dynamically. def establish_mongo_connection publish_detail Mongoid.disconnect_clients Mongoid.clients.clear Mongoid.configure do |config| a = config.connect_to…
waqar mirza
  • 555
  • 2
  • 15
3
votes
0 answers

How to set Data type for Hash in rails (Mongoid)

I have a mongoDB scheme something like this new Schema({ productDetail: [ { productYear: String, productNumber: String, productType: [ { type: Schema.ObjectId, ref: 'type' } ] …
3
votes
1 answer

How to create text index in mongoid 5?

I have this in my model index({company_name: 1, first_name: 1, last_name: 1 }) Model.text_search 'something' gives this error Mongo::Error::OperationFailure: text index required for $text query
Faizan
  • 381
  • 1
  • 8
3
votes
2 answers

My Rails 4.2.6 app uses two databases. Can I only use one for testing purposes?

I have a web application in Rails 4.2.6 that was originally using MongoDB (through Mongoid 5) as its main database. However, now I need to connect to a MySQL database to only read some additional data for my app. So far, I have required ActiveRecord…
Daniel Ruiz
  • 600
  • 5
  • 12
3
votes
1 answer

Mongoid 5: find_one_and_update with returnNewDocument

Is it possible, that Mongoid, v5.1.2 ignores the returnNewDocument option when used with find_one_and_update? Consider the following code: next_number = TrackingId.where(id: id).find_one_and_update({ :$inc => { auto_increment_counter: 1 …
23tux
  • 14,104
  • 15
  • 88
  • 187
1
vote
0 answers

How to form Rails Mongo Id Include Query?

I am using MongoId 5.4 Rails 4.2 Want to perform join operation and retrieve the result based on criteria. Band Table has_many :band_histories, dependent: :destroy field :name, type: String field :description, type: String Band…
Kunal Vashist
  • 2,380
  • 6
  • 30
  • 59
1
vote
1 answer

Mongoid 'set' value in nested hash

I got the following document { a: { b: { c1: 1, c2: 2 } } } I want to atomically modify only c1 to 8 I do document.set('a.b.c1': 8), but entire value of 'b' changes to {c1:8}. this is my class class C include Mongoid::Document field :a, type:…
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
1
vote
1 answer

how to delete a key from mongoid hash field

I have a hash field in Mongoid document like < _id: 58a202d407953817ece2989c, d: {"a"=>"b", "c"=>"d"}> i want to pop key a from it so that hash filed contain only c how to do this in mongoid?
Aki Singh
  • 11
  • 1
1
vote
0 answers

Association error within Rails 4 app with mongoid + simple_form + devise

As mentioned on title, I made a Rails 4 app that contains mongoid (5.1.3) devise (4.2.0) simple_form (3.2.1) I set up my app with commands below: rails g mongoid:config rails g simple_form:install --bootstrap rails g devise:install rails g devise…
ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
1
vote
1 answer

Finding name variations from large list Ruby

I have a large list of words maybe 300-600 words and I want to make it so that as my user begins typing in a word the app suggest words that it found from my specific list that are close to the spelling that person is giving. Kind of like…
SupremeA
  • 1,519
  • 3
  • 26
  • 43
1
vote
1 answer

Reload only one attribute mongoid

I have model object implementing Mongoid::Document model has an attribute called name I need to reload only name of model Is there something shorter than Model.only(:name).find(model.id).name like model.reload(:name)
Benjamin Harel
  • 2,906
  • 3
  • 24
  • 32
0
votes
0 answers

mongo cluster connection issue with Sidekiq + Rails

I am using rails - 6.0.3, mongoid - 7.0.13 along with using mongo atlas cloud mongo cluster connection with rails application is working fine but with sidekiq job we are getting exception - ArgumentError: Host…
1
2