Questions tagged [moped]
62 questions
22
votes
1 answer
Heroku & MongoHQ: ActionView::Template::Error (The operation: #
I have a Rails 3 app with MongoID 3 deployed successfully to Heroku (using MongoHQ) -- but then something happened (cannot pinpoint what exactly it was) and the build started crashing on Heroku.
So this is the error I get:
TLDR:…

herb
- 840
- 9
- 16
13
votes
1 answer
Rails Mongoid fails to authenticate - failed with error 13: "not authorized for query on my_db.my_collection"
This issue was said to be resolved the latest version of Moped but still happens to me.
I have a rails 4.2 app with Mongoid, created a user for a MongoDB DB with readWrite and dbOwner roles, and set auth=true in the mong.conf file.
I can perform any…

Orr
- 4,740
- 3
- 28
- 31
9
votes
1 answer
Mongoid/Moped errors when processing jobs with Sidekiq
I am seeing a ton of jobs failing when running Sidekiq that are all related to connectivity issues with my Mongo database. I'm stress testing the machine with lots of load, so I queued over 18,000 jobs each with a 5 second retry upon failure. Some…

randombits
- 47,058
- 76
- 251
- 433
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
1 answer
Moped::Errors::OperationFailure failed with error "no such cmd
I recently upgraded from mongoid 2.0.2 to mongoid 3 with rails 3.2.12 and ruby 1.9.3 .
Following issue comes when save command excutes => @new_node.save
Moped::Errors::OperationFailure (The operation: #
6
votes
2 answers
Moped: get id after inserting
When I use mongo-ruby-driver and I insert new document it returns generated '_id':
db = MongoClient.new('127.0.0.1', '27017').db('ruby-mongo-examples')
id = db['test'].insert({name: 'example'})
# BSON::ObjectId('54f88b01ab8bae12b2000001')
I'm…

rjurado01
- 5,337
- 3
- 36
- 45
5
votes
3 answers
Pluck multiple and/or nested fields on mongoid
I have the following query db in mongodb that returns exactly what I need:
db.collection.find({field1: 2801394}, {name: 1, field2: 1, _id: 1, "field3.2801394": 1})
Note field 3 is a hash, and the key used here is the same as for field1 by the…

user2008476
- 71
- 2
- 5
4
votes
1 answer
Mongoid3/Moped: database=admin command={:ismaster=>1}
I've upgraded my Rails app to 3.2.8 and Mongoid 3/Moped. Everything works fine in development, on my development machine while set to production, and rails c works fine on my production setup as well. However, the app doesn't start (deployed on…

Avishai
- 4,512
- 4
- 41
- 67
3
votes
0 answers
Mongoid 4 / MongoDB 2.4+ "Freezing" Issue
I've had a strange issue since with maintaining a connection to mongodb using Mongoid. I thought this was originally due to upgrading to Rails 4.0+ (which required Mongoid/Moped to be updated), but I've also had this issue with other Rack-based apps…

Alex B.
- 590
- 4
- 17
3
votes
1 answer
Mongoid with Rails 4 - Could not connect to a primary node ... resolved_address=nil
I installed MongoDB locally, and am stuck at this error when trying to use Mongoid/Moped on Rails 4 / Ruby 1.9.3 / Windows 7:
"Could not connect to a primary node for replica set #

corg
- 428
- 4
- 14
3
votes
3 answers
How to reset a mongoid 3 database connection
In Mongoid 2.x one could execute Mongoid.database.connection.close to reset a database connection. This specific API is no longer available in Mongoid3, what is the new way to reset a connection?
Motivation: interrupting a query while it's…

ccurtisj
- 388
- 2
- 13
2
votes
0 answers
mongo query through ruby script takes long time execute
I have a ruby script which is connecting to a mongo db on remote server and does find_by query. Sometimes the execution takes less than 1 second where as sometimes it takes around 15mins to execute.What could be the reason for this…

Praneetha
- 303
- 4
- 17
2
votes
1 answer
How to force moped to read from Mongo secondary replica set member running with a delay
I have a ruby on rails based application. Objective is to read from a mongo replica set member that is:
secondary
delayed by x seconds
priority: 0
Placed in a separate data center.
DETAILS: I have a production cluster running that uses mongo…

wayne
- 393
- 2
- 13
2
votes
3 answers
found record through association
I have a modeling like this
class Room
include Mongoid::Document
field :name, type: String
has_many :messages
end
class Message
include Mongoid::Document
field :content, type: String
belongs_to :room
end
I need to found the top 3 rooms…

Luiz E.
- 6,769
- 10
- 58
- 98
2
votes
1 answer
How to update with upsert option with Ruby Mongoid Moped
I need to update some data in the MongoDB if data already exists, if not to upsert or create record with this data.
My models are:
class Garage
include Mongoid::Document
include Mongoid::Attributes::Dynamic
has_many :cars
end
class Car
…

arthur-net
- 1,138
- 1
- 13
- 34