Tagged Questions
2
votes
1answer
30 views
Ruby: Binary String to IO
I have a string of binary data and I need it as an IO object. So I tried this:
r, w = IO.pipe()
w << data
But it fails with this error:
Encoding::UndefinedConversionError ("\xD0" from ...
0
votes
1answer
14 views
mongoid before_destroy callback on has_and_belongs_to_many association
I have a simple has_and_belongs_to_many relation set up in Mongoid like so:
class Post
...
has_and_belongs_to_many :authors
scope :live, lambda{ published.where(:published_at.lt => ...
0
votes
1answer
15 views
Indexing coordinates in MongoDB not working
I have a model that stores coordinates and the coordinates are indexed
class Place
include Mongoid::Document
include Mongoid::Spacial::Document
field :coordinates, type: Array, spacial: true
...
0
votes
1answer
24 views
Accessing attributes from another model but same controller
I have an events controller with a payment method that calls save_with_payment method from the registration model, the method in the registration model needs to get the price of the event to build the ...
1
vote
1answer
22 views
Ruby Mongo gem bulk insert of enumerable
I am using ruby 1.9.3 with the twitter and mongo gems.
I have the following code working:
Twitter.user_timeline("GSElevator", :count => 200, :exclude_replies => "true", :include_rts => ...
0
votes
1answer
33 views
Foreign Keys and Mongoid
Are foreign keys explicitly required in relationships between two models in Mongoid? For example.
class User
include Mongoid::Document
has_many :posts
end
class Post
include Mongoid::Document
...
2
votes
1answer
47 views
MongoMapper syntax error on hyphenated key name
Trying to setup a MongoMapper object for a Document with a key named 'buy-only'. When I try to start the application, I'm getting this
(eval):1: syntax error, unexpected '-', expecting ';' or '\n'
...
0
votes
1answer
28 views
Mongoid relationship gives “wrong number of arguments (1 for 2)” error
I'm migrating from mongo_mapper to mongoid in Sinatra, and I keep getting this "wrong number of arguments (1 for 2)" error in my tests when there is a relationship with a custom relation name, which ...
0
votes
1answer
20 views
How do I select a subset of fields for ALL records in mongo via the ruby interface?
I'm trying to select everything in a collection, but only a subset of fields.
collection.find
works, but I'd like to do something like
collection.find( {}, :fields => ['field1', 'field2'] )
...
0
votes
1answer
24 views
Retrieve an embedded document using Mongoid
I have a Mongoid document called Equipment which can embed multiple Question documents. Here are the document schemas:
class Equipment
include Mongoid::Document
include Mongoid::Timestamps
...
2
votes
0answers
81 views
Persisting a Ruby-based Petri net object model
I wrote a Petri net domain model in pure Ruby and I plan to persist it with MongoDB. Petri net places and transitions have "arcs" (place - transition arrows) relations, and perhaps other relations, ...
1
vote
1answer
28 views
Parent fields are all nil when accessed by child (embedded 1-n)
I have a 1-n relationship defined as follows:
class User
field :email, type: String
embeds_many :papers
end
class Paper
embedded_in :user
end
If I try and access the parent fields (user) ...
0
votes
2answers
29 views
nested field query for mongodb (using ruby)
Sup, good folks of the internet.
Does anyone know how to make nested queries for mongodb? This is probably best explained by an example. To retrieve specific fields, I can use the :fields option to ...
0
votes
1answer
35 views
Why can't I display the next three future events from my model?
I am attempted to display the next three future events from my database but the code below displays nothing. I can't see what I have done wrong.
This is the event controller:
class EventsController ...
0
votes
1answer
15 views
Difference between timeout and connect_timeout options on Ruby Mongo driver
We need to set a timeout value when connecting to Mongo via Ruby. We're on Mongo 2.2.
Should we use :timeout or :connect_timeout? We see code snippets using both options here on SO and elsewhere. ...