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
0
votes
1 answer

Rectify gem, mongo, tests ActiveRecord::ConnectionNotEstablished

After adding rectify gem all tests fail with error: ActiveRecord::ConnectionNotEstablished: No connection pool for ActiveRecord::Base We are using: Gems: Rails 4.2.8 Mongoid 5 Rectify 0.9.1 Rspec 3.4.4 Another: Os: Ubuntu…
0
votes
1 answer

Mongo SSL config with CA cert only works for rails console, not rails server

I am trying to configure a Rails 4.2.6 app to connect over SSL to a MongoDB cluster on compose.io. The app uses the mongo 2.4.1 and mongoid 5.1.5 gems. Compose.io MongoDB clusters use self-signed SSL certificates so I downloaded the CA certificate…
Jon Ekdahl
  • 382
  • 1
  • 3
  • 11
0
votes
1 answer

Warning on updating Mongoid Gem to Version 5 Issue

I have updated the mongoid gem to 5 from mongoid-4 on rails 4 application. I am facing the following warning on app restart W, [2017-02-15T13:59:49.356541 #14483] WARN -- : MONGODB Unsupported client option 'max_retries'. It will be ignored. W,…
tessie
  • 964
  • 3
  • 14
  • 24
0
votes
2 answers

mongoid create text index on all text fields on model

Can I create text index for all fields in ruby model like with this mongodb command: db.documents.createIndex({ "$**": "text" }, { name: "TextIndex" }) Also can we somehow add number properties to index. I've tried like this but it doesn't def…
malibeg
  • 2,237
  • 2
  • 17
  • 21
0
votes
1 answer

Nested Attributes Unpermitted wit Embedded Mongoid Document via AJAX

I am trying to submit a document and an embedded document via Ajax call but keep receiving an "Unpermitted parameter" exception. This is my model: class UserForecast ... embeds_many :time_entries accepts_nested_attributes_for…
Boenne
  • 605
  • 4
  • 17
0
votes
1 answer

How to add documents (ObjectId's) to has_many and has_and_belongs_to_many relationships using Ruby on Rails with Mongoid?

I'm building a database in Ruby on Rails using Mongoid that includes the following three collections Residence, Map, and Router: residence.rb class Residence include Mongoid::Document include Mongoid::Timestamps include Mongoid::Geospatial …
0
votes
1 answer

MongoID 5 Aggregations: NoMethodError: undefined method `[]' for Aggregation

After upgrading to MongoID 5 I'm getting this error: NoMethodError: undefined method `[]' for # The code looks like: result = ::Presentation::Interaction.collection.aggregate( [ user_match_criterias_live(conference), …
hcarreras
  • 4,442
  • 2
  • 23
  • 32
0
votes
1 answer

Mongoid can't save document with a belongs_to/has_many relationship. Circular dependency

I have 2 Mongoid classes: class Reservation include Mongoid::Document belongs_to :listing, class_name: 'Listing', inverse_of: 'Reservation' end class Listing include Mongoid::Document has_many :reservations, class_name: 'Reservation',…
Shiyason
  • 759
  • 7
  • 16
0
votes
2 answers

What is a good way to `update_or_initialize_with` in Mongoid?

Each user has one address. class User include Mongoid::Document has_one :address end class Address include Mongoid::Document belongs_to :user field :street_name, type:String end u = User.find(...) u.address.update(street_name: 'Main…
B Seven
  • 44,484
  • 66
  • 240
  • 385
0
votes
1 answer

Undefined method `to_criteria' with Rails 4.2.7, Pundit, Mongoid and RailsAdmin

I have a Rails 4.2.7 app with rails_admin (0.8.1), pundit (1.1.0) and mongoid (5.1.4) I created Campaign scaffold and added authorize @campaign to set_campaign in CampaignController. when I browse to…
0
votes
1 answer

How to enable Mongo indexes in Rails test environment with Mongoid driver?

I have a MongoId model like this: module Acme class Account include Mongoid::Document include Mongoid::Timestamps field :username index({'username': 1}, {unique: true}) end end I want to write some unit tests but I want this…
p.matsinopoulos
  • 7,655
  • 6
  • 44
  • 92
0
votes
1 answer

Rails sort date by upcoming first, then descending

I have a collection of Appointments which have a start_date DateTime field. I need to sort those appointments so I have The upcoming appointments first Then the "past" appointments, most recent first Ie suppose I have I'm using relative times…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
1 answer

mongoid embeds_many associated collection remain empty

I have two models class Supplier < User include Mongoid::Document embeds_many :images accepts_nested_attributes_for :images end class Image include Mongoid::Document embedded_in :supplier end When I save images in nested form it gets save…
Faizan
  • 381
  • 1
  • 8
0
votes
1 answer

Mongoid find_and_modify deprecated

I'm currently updating a Rails app to Mongoid 5. I've having trouble updating some code that uses a deprecated method (find_and_modify). Any help would be appreciated. In Mongoid 4, I have this method to find and upsert: LineItem.where({ date:…
Dowker
  • 69
  • 4
0
votes
1 answer

Mongoid Rails update error for documents having embedded documents

I have a model called User. User embeds_many posts. For User records having embedded posts, whenever I try to update any other field, I am getting the error NoMethodError: undefined method `each' for false:FalseClass I am using update as…
Sebin
  • 1,044
  • 1
  • 8
  • 21
1
2