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

Comparability Issue rails 4 beta, ruby 2.0.0, mongoid

I am creating a test application using following versions of rails, ruby and mongoid. rails 4 beta ruby 2.0.0 mongoid 3.1.2 My GemFile looks like this gem 'rails', '4.0.0.beta1' ruby '2.0.0' gem 'mongoid', '~> 3.1.2' gem 'bson_ext' But when i run…
Zeeshan
  • 351
  • 4
  • 8
14
votes
4 answers

Mongoid Without Rails

I'm playing with a standalone ruby application and can't configure Mongoid 3.0.13 to work. I've run across a couple example apps that have configuration blocks like: Mongoid::Config.instance.from_hash({"database" => "oid"}) Or Mongoid.configure…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
14
votes
5 answers

How to programmatically get the current database Mongoid is writing to?

I am talking to multiple databases using Mongoid.override_database("database_name") using Mongoid with rails. How do I find the current database programmatically? Mongoid docs on sessions: http://mongoid.org/en/moped/docs/driver.html define methods…
11
votes
6 answers

Rails Engine + Mongoid: No configuration could be found for a session named 'default'

I've created a Rails Mountable App and added 'mongoid' and 'rspec' gem's. If I try to run my specs now I get the following error: Mongoid::Errors::NoSessionConfig: Problem: No configuration could be found for a session named 'default'. Summary: …
wintersolutions
  • 5,173
  • 5
  • 30
  • 51
11
votes
2 answers

Unicorn triggers mongoid error during assets precompile

I have a rails app using Mongoid 3 running on Heroku. I've just updated it to use Unicorn. When I try to deploy it to Heroku I get the following error : Running: rake assets:precompile rake aborted! undefined method `match' for nil:NilClass …
AdrienF
  • 859
  • 1
  • 6
  • 19
10
votes
2 answers

Moped::Errors::ConnectionFailure Could not connect to any secondary or primary nodes for replica set

I had to forcefully shutdown my Ubuntu system after it got hanged. Now I get this error while trying to run my Rails app. Moped::Errors::ConnectionFailure (Could not connect to any secondary or primary nodes for replica set
Santhosh
  • 28,097
  • 9
  • 82
  • 87
9
votes
1 answer

Advice on migrating from MongoMapper to Mongoid?

It seems like Mongoid is now the superior ORM for Mongo based on performance and development activity. Unfortunately, we're on MongoMapper and need to migrate. Are there any concerns or stumbling blocks we should be aware of? We have found a few…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
9
votes
3 answers

How to do an upsert / push with mongoid / moped

I'm using Mongoid (v3) to access MongoDB, and want to perform this action: db.sessionlogs.update( {sessionid: '12345'}, /* selection criteria */ {'$push':{rows: "new set of data"}}, /* modification */ true /* upsert */ ); This works…
Leopd
  • 41,333
  • 31
  • 129
  • 167
8
votes
4 answers

How do I rename a mongo collection in Mongoid?

I have a collection called artists, i'd like to rename it to artist_lookups. How do I do this?
Billy
  • 563
  • 5
  • 15
7
votes
1 answer

Store functions in mongodb using Mongoid 3

Just as the title suggests. I am not able to find anything related to Mongoid 3. The things I found only apply to old versions of mongoid that didn't use Moped. I found this and it doesn't work: def self.install_javascript getWeekJs =…
Oktav
  • 2,143
  • 2
  • 20
  • 33
7
votes
2 answers

Connecting to two databases Mongoid

I have two databases that I have to use in my application. I have the following in my mongoid.yml: development: # Configure available database sessions. (required) sessions: # Defines the default session. (required) default: #…
senthil
  • 1,307
  • 1
  • 11
  • 23
6
votes
2 answers

Strong consistency for a Rails model in Mongoid 3

I want all of my db interactions for a specific model to go through the mongo primary in my cluster, so I set the model to use strong consistency. class Photo include Mongoid::Document with consistency: :strong field :number, type: Integer …
jstim
  • 2,432
  • 1
  • 21
  • 28
6
votes
0 answers

BSON::Binary::InvalidType "my file content" is not a valid binary type. Please use one of :generic, :function, :old, :uuid_old, :uuid, :md5, :user.):

I am trying to save files into gridfs using carrierwave mongoid in rails. I am unable to do this process due to this error: BSON::Binary::InvalidType ("my file content" is not a valid binary type. Please use one of :generic, :function, :old,…
6
votes
2 answers

How to get print output for debugging map/reduce in Mongoid?

I'm writing a map/reduce operation with Mongoid 3.0. I'm trying to use the print statement to debug the JS functions. This is a troubleshooting suggestion from the MongoDB docs, e.g.: reduce = %Q{ function(user_id, timestamps) { var max =…
Wolfram Arnold
  • 7,159
  • 5
  • 44
  • 64
5
votes
0 answers

Mongo + Mongoid Exception failed with error "not master"

I have a simple replica set configured as follows: mongo1 (primary) mongo2 (secondary) mongo3 (arbiter) It functioned correctly for around a month and then we started seeing intermittent exceptions along the lines…
TalkingQuickly
  • 538
  • 5
  • 15
1
2 3
14 15