Questions tagged [mongoid3]

Version 3 of Mongoid, an Object-Document-Mapper (ODM) for MongoDB with Ruby. Use this tag for questions relating to this specific version.

Version 3 of Mongoid (an Object-Document-Mapper (ODM) for MongoDB). For a deeper description of Mongoid, see the main Mongoid tag.

Primary tag:

211 questions
1
vote
1 answer

Mongoid Errors When Doing Model.first

I just upgraded to Mongoid 3, but I'm having a very strange issue. I have a model called "Event" and another called "Team" - each has has_and_belongs_to_many relationship. After upgrading, I simply can't do Event.first or Event.last on the console.…
K2xL
  • 9,730
  • 18
  • 64
  • 101
1
vote
1 answer

Mongoid 3 and Mongodb querying secondaries for specific queries

I have a mongodb replicaset configured with 3 replicas. My configurations are staging: sessions: default: hosts: - xx.x.x.xxx:27017 - xx.x.x.xxx:27017 - xx.x.x.xxx:27017 database: mongoid_staging …
Sid
  • 6,134
  • 9
  • 34
  • 57
1
vote
0 answers

`rescue in depend_on': No such file to load -- mongo when running rspec

I'm in the process of updating an app from rails 3.1 to 3.2 and from mongoid 2 to mongoid 3. When I run the application everything runs fine but when I try to run the specs I get the following error (the full stacktrace is at the bottom of this…
Conor
  • 775
  • 3
  • 10
  • 23
1
vote
0 answers

Mapping relationships with custom names in Rails Admin

I am using rails admin, and it works fine except for a pretty big issue. I have custom relationships in mongoid, and rails admin is not allowing me to edit that field. My relationship definition in mongoid: class Content belongs_to :lesson,…
meow
  • 27,476
  • 33
  • 116
  • 177
1
vote
2 answers

How to initialize field based on another field?

I have a user model with :email and :user_name, I want to auto initialize :user_name with part of :email. class User include Mongoid::Document field :email field :user_name end I use simple_form to create the user. How can I initialize…
AZ.
  • 7,333
  • 6
  • 44
  • 62
1
vote
1 answer

Mongoid failing to find document by nested ID

I have a collection with documents that look something like this: { _id: ObjectId("521d11014903728f8d000006"), association_chain: [ { name: "Foobar", id: ObjectId("521d11014903728f8d000005") } ], …
Andrew
  • 227,796
  • 193
  • 515
  • 708
1
vote
1 answer

Search json field with mongoid

I've got the following MongoDB/Mongoid document: #{ "id"=>100, "deleted_at"=>nil, "created_at"=>2011-10-06…
d_ethier
  • 3,873
  • 24
  • 31
1
vote
1 answer

Fire Child Callbacks on parent save (Force)

I am trying to trigger child callbacks for embeds many relations. For example: class User embeds_many :phones, cascade_callbacks: true end class Phone embedded_in :user, inverse_of: :phones before_save :callback_after_save def…
nightf0x
  • 1,969
  • 3
  • 17
  • 24
1
vote
4 answers

undefined method `paginate' for Array on Rails 3 with mongoid

Trying to use will_paginate gem. My Gem file has: gem 'will_paginate', '~> 3.0.0' My orders_controllers.rb: def index @orders = Order.all.paginate(:page => params[:page], :per_page => 20) respond_to do |format| format.html #…
Askar
  • 5,784
  • 10
  • 53
  • 96
1
vote
1 answer

Rails app with Mongoid not saving on update

I'm making a Rails app that uses Mongoid and devise. Currently, the functionality's pretty basic, but it's not working like I expect it to. In particular, update isn't working at all. I can create a user, but when I go back to update it, it doesn't…
Sasha
  • 6,224
  • 10
  • 55
  • 102
1
vote
1 answer

Mongoid batch insert with complicated schema?

I've been going all over the web looking for a solution to my problem. I' m using Mongoid to write a set of data to MongoDB. I'm trying to do a batch insert with mongoid as follows: class Geonode include Mongoid::Document include…
inquire
  • 761
  • 1
  • 7
  • 13
1
vote
1 answer

Mongoid unique model references

I'm using Mongoid 3. I have a simple class Tour and references multiple Itineraries. Is there a way that I can validate that for each tour, the itineraries' dates are unique, i.e. I can't have 2 itineraries of the same date for a single tour. class…
netwire
  • 7,108
  • 12
  • 52
  • 86
1
vote
1 answer

Mongoid Identity Map setting not taking effect in Rails console

It does not appear that the identity_map setting is getting picked up from the config/mongoid.yml file. Here's the file: development: sessions: default: uri: mongodb://localhost:27017/test_development options: &defaultopts …
Aaron K
  • 6,901
  • 3
  • 34
  • 29
1
vote
1 answer

How to sort by nested field value with Mongoid?

Let's say I have a User with a field name, and which has_many teams, and a Team that belongs_to a user, and belongs_to a sport. A Sport has a field name and has_many teams. I want to walk through the sports, do some stuff, and collect an array of…
Dave Sag
  • 13,266
  • 14
  • 86
  • 134
1
vote
0 answers

MongoDB/Mongoid Tree Structure

I'm currently speccing out the architecture for a project. Its on a fairly tight timeline, will need to support a few hundred thousand users fairly soon after launch, and its business logic and model are tied tightly to an extended tree structure. I…
loneaggie
  • 297
  • 2
  • 8