Questions tagged [moped]
62 questions
2
votes
1 answer
Moped::Errors::OperationFailure when creating an embedded object
I'm using mongoid 3.1.4 altogether with moped 1.5.1, mongodb 2.4.1, and ruby 1.9.3.
I have next models:
class Practice
include Mongoid::Document
embeds_many :distresses
end
class Distress
include Mongoid::Document
embedded_in…

mgallardoz
- 51
- 4
2
votes
1 answer
Moped: Running naked mongo command
I am getting no such command error while running stat command as in
db.stat() in mongo console
But running it from moped gives error
session.command(stat: 1)
failed with error "no such cmd: stat"

ducktyped
- 4,354
- 4
- 26
- 38
2
votes
1 answer
Sudden problems connecting
I have a Rails 4.0 app that's using MongoDb. I'm using Mongoid as the ORM. Up until this afternoon, everything was working just fine.
Suddenly, I'm getting random timout errors.
First a message from MOPED:
MOPED: Retrying connection attempt 1 more…

user2825755
- 25
- 2
2
votes
1 answer
Iterating over a collection in MongoDB for updates
I'm iterating over a collection (running Moped as Ruby driver) but how to update one field for every document?
irb> session = Moped::Session.new(["127.0.0.1:27017"])
irb> session.use :demoapp
irb> users = session[:users]
irb> users.find.each {|u|…

ctp
- 1,077
- 1
- 10
- 28
2
votes
1 answer
update removed from moped::colllection - NoMethodError: undefined method `update' for #
I am new to working with mongodb & mongoid.. This is a rails app that was on mongoid 2 at some pont and have since moved to mongoid 3
I am trying to run the migrations, one of which has the following
Assessment.collection.update({'result_access' =>…

theSociableme
- 842
- 1
- 10
- 23
1
vote
0 answers
How to enable exceptions in mongoid/moped/mongodb
My setup fails silently when I order_by an unknown attribute. Is there a way to change this behavior, to fail fast with an error/exception?
It makes debugging code extremely difficult.

Dogweather
- 15,512
- 17
- 62
- 81
1
vote
0 answers
Moped 2.0.7 undefined method `session'
I have no idea what's going on here.
I upgraded to MOPED 2.0.7 and I'm getting this undefined method `session' for #
User.tags_index_collection
=> #

Ben
- 2,957
- 2
- 27
- 55
1
vote
1 answer
Storing a collection of mongoid documents with one operation
When using Moped gem, I can store an array of hashes with:
users = [{username: "ben", password: "123456", type: "admin" }, {username: "joe", password: "abcd1234" }]
Mongoid::Sessions.default["collection"].insert(users)
With mongoid documents it…

benams
- 4,308
- 9
- 32
- 74
1
vote
1 answer
save / update a (Moped) BSON::Document with ruby
I tried many ways to update an existing bson document, but it never changes in my mongodb:
col = db["collection"]
col.insert({"ben": 1})
doc = col.find().to_a.first
# => {"_id"=>BSON::ObjectId('556c7f1b167e70640070a4d9'), "ben"=>1}
first attempt to…

benams
- 4,308
- 9
- 32
- 74
1
vote
0 answers
ConnectionPool::PoolShuttingDownError thrown once in a while by application_controller rails using Mongodb replicaSet
I have a RoR application running on two different server. They run the same version of the app and are similar in configuration. I have a Mongodb replica set running on both the server with a third server as an arbitrary server.
Everything runs…

Harry Bomrah
- 1,658
- 1
- 11
- 14
1
vote
1 answer
Mongoid Error Redirection
I would like to be able to redirect the output raised from an error from mongoid. I have some simple code in the following layout:
begin
[ruby code here to query database]
rescue [Moped Exception here] => e
puts e.message
end
When an error…

fowlball1010
- 343
- 3
- 13
1
vote
0 answers
Moped vs Mongo-ruby-driver
I'm going to write a ruby application and I need access to mongodb database.
What are the diferences between Moped and Mongo-ruby-driver?
What are the pros and cons of each?

rjurado01
- 5,337
- 3
- 36
- 45
1
vote
1 answer
mongoid: select elements that have at least n elements in array
In mongoid you can query items that have at least one element in array:
Item.any_in(tag_ids: [id1,id2,id3])
You can also select elements that have all elements in array:
Item.all_in(tag_ids: [id1,id2,id3])
My Question: Is there any way to query…

aherve
- 3,795
- 6
- 28
- 41
1
vote
0 answers
Padrino Admin (12.0) + Mongoid: escaped quotes break MongoDB array syntax
Whenever I edit an object with an array field with Padrino Admin interface, the quotes are escaped and MongoDB doesn't recognize the array as an array anymore.
Fields are correctly defined as arrays in the object model definitions.
Any…

bcsantos
- 2,635
- 5
- 21
- 22
1
vote
0 answers
nested mongodb query with moped/mongoid?
I'd like to write some nested queries using mongodb, but I'm very new with mongoid/moped. For the sake of the example, would it be acceptable to write some friends of friends query as follows ?
u1 = User.last # get some user
friends_of_friends =…

aherve
- 3,795
- 6
- 28
- 41