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

Meteor mongo $near not sorting correctly

I am trying to get the nearest postings in my meteor project. It is returning my four postings, but not sorted by distance from origin. I added these two indexes: db.postings.ensureIndex({ loc : "2d" }) db.postings.ensureIndex({ loc : "2dsphere"…
timmyg13
  • 503
  • 1
  • 5
  • 15
2
votes
1 answer

Rails/MongoDb Search and Refine Search Implementation

I have a search functionality in my app which works as the following Homepage: user selects location from a drop-down and then enters a search key-word and searches to get a set of results Search Page (REfine Search Options): Once the user hits…
2
votes
1 answer

MongoDB: using limit and skip on complex sort order in either direction

I have a complex sort order using several fields. The 'entry object' is the first item in the first batch defined by a query. I'm trying to create an infinite scroller where the entry item is shown at the top--scrolling down works as expected and…
pferrel
  • 5,673
  • 5
  • 30
  • 41
2
votes
2 answers

How to add_to_set to multiple arrays and touch in a single query using mongoid

I am looking to add to multiple sets, and at the same time update the updated_at timestamp (touch). I could do this using the mongo driver: db.mycollection.update({"_id": ObjectId("911")}, { $addToSet: { "hashtags": {$each: ["#test1", "#test5"]},…
amit_saxena
  • 7,450
  • 5
  • 49
  • 64
2
votes
0 answers

can't modify frozen Hash in mongoid has_one dependent destroy

when I am using mongoid with Rails , I associated my model with has_one relation and used dependent destroy like this class MyModel has_one :foo , :dependent => :destroy end class Foo belongs_to :mymodel end my_model.foo =…
ratnakar
  • 352
  • 1
  • 11
2
votes
1 answer

Nested Querying in Mongoid in 2013

So this question is two years old: Querying embedded objects in Mongoid/rails 3 ("Lower than", Min operators and sorting) and the way it recommends to query nested objects with less than or greater than: current_user.trips.where('start.time' =>…
Niall Paterson
  • 3,580
  • 3
  • 29
  • 37
2
votes
1 answer

Rails blog using Mongoid - Auto generate Short URL on post creation

I have a simple blog engine using Rails and Mongoid ORM. I have 2 models in the blog, 'Article' and 'Url'. The Article model contains all of the post content, and the Url class is the generator function that takes the slug of the Article and…
Smith
  • 21
  • 1
2
votes
1 answer

Best strategy for picking random documents in Mongoid

I need to pick a random document out of my database and wanted to know a better strategy than the Ruby shuffle method that is less resource intensive for large databases.
Rick
  • 8,366
  • 8
  • 47
  • 76
2
votes
3 answers

MongoDB/Mongoid: search for documents matching first item in array

I have a document that has an array: { _id: ObjectId("515e10784903724d72000003"), association_chain: [ { name: "Product", id: ObjectId("4e1e2cdd9a86652647000003") } ], //... } I'm trying to…
Andrew
  • 227,796
  • 193
  • 515
  • 708
2
votes
1 answer

custom image size into devise + facebook-omniauth

I'm using mongoid, rails 3.2.10 and omniauth on devise.. and trying to set up custom image_size of facebook profile image url config.omniauth :facebook , API_KEYS['facebook']['api_key'], API_KEYS['facebook']['api_secret'], :image_size => {:width =>…
2
votes
1 answer

mongoid and kaminari throws undefined method page

When using kaminari with mongoid, I get the error undefined method `page' for # Not sure what is wrong. I even tried running Item.page(params[:page]) and I get the error NoMethodError: undefined method…
Amit
  • 3,952
  • 7
  • 46
  • 80
2
votes
1 answer

in Mongoid 3, can I build a Queryable and then pass it to a where method?

The docs between Origin and Mongoid aren't really clear on how to use a Origin::Queryable object. Can I build a Origin::Queryable object up and then pass it to a ModelName.where method? It seems that I can't but on the other hand, seems like a…
jcollum
  • 43,623
  • 55
  • 191
  • 321
2
votes
0 answers

Custom fields with mongoid

I started to use the mongoid gem in my project, and I'm a little confused about how it store and get the information on the database. I have fields of specifics types in my models, but when I get it from the DB it returns a Hash. Here is my…
2
votes
1 answer

Heroku not using the specified Ruby 1.9.3

Upgrading to Mongoid 3 and Ruby 1.9.3. Trying to use Ruby 1.9.3 on Heroku Cedar Stack. I have added the below to the top of my Gemfile: source 'http://rubygems.org' ruby "1.9.3" Pushing to Heroku, it seemed to be working -----> Heroku receiving…
Bashar Abdullah
  • 1,545
  • 1
  • 16
  • 27
2
votes
1 answer

mongoid convert has_many relation into embeds_many

I made the early novice-mongodb mistake awhile back and make a lot of has_many relations when I should have been embedding them. My question is how can I now convert my records from a polymorphic has_many scenario to embeds_many? #Place.rb has_many…
ere
  • 1,739
  • 3
  • 19
  • 41