mongoid

Ruby Mongo or Mongoid concurrency problem

I am having what I think must be a concurrency problem. I am using passenger, rails 2.3.5, mongoid 1.9.2, and mongo ruby driver 1.0.9. I am using jQuery to request data that is pulled from MongoDB and then rendered in the browser. Everything is working great until I started to make two such requests at the same time. In the model the...

mongoid querying problem

I have a Three documents, here is a sample with fields not shown class College include Mongoid::Document references_many :students,:stored_as => :array, :inverse_of => :colleges end class Student include Mongoid::Document embedded_in :college, :inverse_of => :students embeds_one :mark end class Mark include Mongoid::Docum...

Embedding message replies inside message parent with mongodb using mongoid

I think it's a best practice to embed replies to a specific message inside that message and I'm trying to implement it using mongoid. here is what I have class Message include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paranoia field :subject field :body field :sender_deleted, :type => Boolean, :defaul...

How can I query mongodb using mongoid/rails without timing out?

I have a rake task that processes a set of records and saves it in another collection: batch = [] Record.where(:type => 'a').each do |r| batch << make_score(r) if batch.size %100 == 0 Score.collection.insert(batch) batch = [] end end I'm processing about 100K records at a time. Unfortunately at 20 minutes, ...

Mongoid Pagination problem

Hi, I'm struggling to paginate using mongoid. I'm able to call paginate on my collection object like @results = @collections.paginate :page => 1, :per_page => 10 but how it needs to be referred in view? In my view I have rendered the collection in partial as <%= render :collection => @collections, :partial => collect.xml %> <%= will...

Rails: Store JSON in MongoDB

Hello, I am getting multiple similar JSON object from a remote site and looking to store them in a local MongoDB. What would be the best way to do this ? (Preferably via Mongoid or Mongo-mapper gems) Thanks ...

Problem converting mongodb id (_id) to string

Im having serious issues converting mongo id from object to string. The following code $cursor = $connection->mydb->collectn->findOne(); var_dump($cursor['_id'].''); var_dump((string) $cursor['_id']); returns string(12) "Object id #6" while what I was expecting is a textual representation of the hex digits of the id. It however wo...

How connect to db depending on @request.host value?

How connect to different db depending on @request.host value? Using Sinatra and MongoDB with Mongoid. I need to read a Sintra application's menu, data ... from different databases. I wish to deploy it only in one place and depending on request.host(subdomain) value to serve the specific pages. ...