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

Ruby on Rails + MongoDB and MongoID

I have created a sample DB with MongoDB with data from a JSON file on mongodbs website I have imported it with the following command. mongoimport --db test --collection zips --file zips.json The data is being processed and when I try to search for…
JOSEFtw
  • 9,781
  • 9
  • 49
  • 67
0
votes
1 answer

Keep Child Objects sorted in a field_for

I have this kind of code: user.posts.size #=> 5 already saved user.posts.new(title:"foo") user.posts.new(title:"bar") user.posts.sort_by! { |e| e.title } #=> sort correclty user.posts #=> sorted but with the saved on the top, the new one at the…
Hartator
  • 5,029
  • 4
  • 43
  • 73
0
votes
1 answer

Rails grouped_coolection_select using Mongoid

I am having an issue with the grouped_collection_select using Mongoid. Error message I am getting is: ActionView::Template::Error (undefined method `merge' for :name:Symbol). I am using rails 3.2.12 & latest version of Mongoid. Here is my…
Rich Blumer
  • 960
  • 1
  • 15
  • 26
0
votes
1 answer

Mongoid 3.1 eager loading, json, and field names

Recently updated to Mongoid 3.1 from 3.0.3 and this resulted in some broken code and confusion on my side. Say you have a pair of classes with a belongs_to/has_many relationship, like so: class Band include Mongoid::Document field :name, type:…
Exocentric
  • 98
  • 1
  • 4
0
votes
1 answer

How do i access/select a specific embedded document in mongoid?

Is there a better way to do this? class User embeds_many :groups def group(group_id) gid = Moped::BSON::ObjectId(group_id) self.groups.each.detect{|group| group.id == gid} end end class Group embedded_in…
Kamilski81
  • 14,409
  • 33
  • 108
  • 161
0
votes
1 answer

Mongoid: can I embed many and reference one of the embedded?

I have a list of games. Each one has an embedded list of scores. I'd like to keep a reference to the best score outside of the scores list. class Game include Mongoid::Document field :best_score_id, type: Moped::BSON::ObjectId ... …
jcollum
  • 43,623
  • 55
  • 191
  • 321
0
votes
1 answer

Field content empty when using jquery-tokeninput

I created a form where user can create a profile and select keyword from an autocomplete token field using jquery tokenInput. the problem is as soon as I call .tokenInput() on the textfield, the text in it is not sent when the form is submitted. I'm…
0
votes
1 answer

Rails Mongoid Buyer, Item, Purchase model associations

I'm using Rails 3.2 and Mongoid and I need to set up a simple purchases association. Current I have: class Item has_many :purchases class Buyer has_many :purchases class Purchase has_one :buyer has_one :item I'd like to be able to call all the…
ttringas
  • 23
  • 1
  • 5
0
votes
1 answer

How to move double nested embedded Mongoid documents between single embedded Mongoid documents?

Expanding on the examples in the Mongoid relations documentation, let's say I have three classes... class Band include Mongoid::Document embeds_many :albums end class Album include Mongoid::Document field :name, type: String embedded_in…
0
votes
0 answers

Error_Messages count increasing across all model instances

I am working on a rails 3.2.9 project with a Mongoid back end. I am trying to create posts and if the post is missing a title and content, the model should fail to save which it does properly. When an object is fixed and passes validation, I save it…
Chris Woolum
  • 2,854
  • 20
  • 20
0
votes
1 answer

Devise in mogoid for multi-users with different data

I am using rails 3.2.7, mongoid 3, and i am trying to use devise for users accounts. Before i'll start: i was searching a lot for my problem, and i read many tutorials, byt none fit to my need. I have similar problem like devise and multiple “user”…
0
votes
2 answers

unable to catch ruby exception

Having the following, long running rake batch: class SyncStarredRepo include Mongoid::Document def self.update User.all.map do |user| if user.email != "admin@gitwatcher.com" begin conn = Faraday.new…
Luca G. Soave
  • 12,271
  • 12
  • 58
  • 109
0
votes
2 answers

Error in using Using SSL with MongoDB Monitoring Service

I did edit the settings.py file in my agent installation from the help of http://mms.10gen.com/help/single/index.html#mms-requirements so that the useSslForAllConnections value is True Now when i run python agent.py I get error like this 2012-12-19…
regmiprem
  • 735
  • 2
  • 14
  • 41
0
votes
1 answer

Nesting AND and OR operation with MongoID

I'm trying to figure out how to nest an AND and OR operation with MongoID, like so (taken from something that I used to use with MongoMapper): { :$and=> [ { :$or => [ {"name"=> "joe"}, {"name" => "randy" } { …
0
votes
1 answer

Constants in MongoDB using Moingoid

Are there any good common practices for storing project-wide constants in Mongodb via Mongoid? Is it even worth keeping them in the database?
GTDev
  • 5,488
  • 9
  • 49
  • 84