mongoid

Combine MongoDB and Postgresql in Rails?

Is it possible to combine AR with MongoMapper/MongoID? If so, are there tutorials/documentations for this? ...

protected "reject" method firing with Rails 3 RC, Mongoid, and Recaptcha and RSpec

Please bear with me as I'm a bit new to rails (especially rails 3), and I'm kinda stumped by this. Basically I want to test my CustomersController in my application using RSpec. When I execute my specs trying to perform a post to the create action in my controller, I get this error, and I'm not sure why: 1) CustomersController as gues...

How to implenent mongodb 'includes?' finder condition

I am using Mongoid and have a project and a user model. in the Project model, I have a field class Project include Mongoid::Document field :name field :user_ids, :type => Array end class User include Mongoid::Document field :email end I can find all the users belonging to one project, i.e., 'find this project's users' @p...

How to keep "Cached Values" in Sync in MongoMapper-Model?

Hi together, at the moment I'm doing some tests with MongoMapper. When using relations, http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails sugests to use cached values where it fits... I take a stripped down example from there: class Story include MongoMapper::Document key :title, String key :url, Str...

mongodb mapreduce returning inconsistent results

I have a super simple map reduce test... that isn't working consistently. In a nutshell, I'm just looking for duplicate records. I have a collection that has: GiftIdea - site_id - site_key the site_id + site_key should be unique, but currently isn't. So I have the following map reduce code: var map = function() { print(this.s...

Rails 3, MongoId & bson version problem

I just updated to Rails 3 final. Now I'm having problems with MongoId, Mongo's Ruby driver & bson. When I try to run Rails, I get "You have already activated bson 1.0.7, but your Gemfile requires bson 1.0.4. Consider using bundle exec. (Gem::LoadError)". MongoId requires bson_ext 1.0.4 so I have gem "bson_ext", "1.0.4" in my Gemfile. I ...

Getting Mongoid from params array

In order to find a Root Document that contains a embedded document using MongoID/Rails 3 I need to do my query this way: QuoteRequest.where( "order_request_items._id" => BSON::ObjectID(params[:id]) ).first Is there a way to query without using the BSON::ObjectID ? Thanks! ...

Mongoid/activesupport version problem

I'm attempting to use Mongoid from a plain Ruby script (not via Rails or any other framework) and I think I'm running into some version dependency conflicts: /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': RubyGem version error: activesupport(3.0.0 not >= 2.2.2, < 3.0.pre) (Gem::LoadError) from /opt/loc...

Rails 3.0 ORM agnostic admin plugin

Hey fellow Rail-ists, do know any equivalent of ActiveScaffold but being ORM agnostic or at least for Mongoid? ...

Using Mongoid (Ruby on Rails's MongoDB mapper), do we need to set a type if Cat inherits from Animal?

that is, if app/models/animal.rb has class Animal include Mongoid::Document field :name, :type => String field :birthday, :type => Time end and then in app/models/cat.rb class Cat < Animal include Mongoid::Document field :nail_length, :type => Float end then do you need to set some kind of "type" in Animal to remember it ...

Using Mongoid (MongoDB mapper for Ruby on Rails), why s.save returns true but record not updated?

If the following code is run twice, both times s.save will return true, indicating success, but the second time, the time won't be updated? foo = Foo.new foo._id = 100 foo.time = Time.now p foo.save ...

Carrierwave Mongoid validation of file

Hi I cant figure out how to validate that carrierwave has uploaded a document to my mongoid object. i have a Document Class class Content::Document < Content mount_uploader :attachment, DocumentUploader field :attachable_id field :attachable_type end and an uploader: require 'carrierwave/orm/mongoid' class DocumentUploa...

Need advice on MongoDB Schema for Chat App. Embedded vs Related Documents

I'm starting a MongoDB project just for kicks and as a chance to learn MongoDB/NoSQL schemas. It'll be a live chat app and the stack includes: Rails 3, Ruby 1.9.2, Devise, Mongoid/MongoDB, CarrierWave, Redis, JQuery. I'll be handling the live chat polling/message queueing separately. Not sure how yet, either Node.js, APE or custom Eve...

Replacement for column_names when using Mongoid with rails 3 and dry_crud

I've been doing a spike on Rails 3 and Mongoid and with the pleasant memories of the auto scaffolding in Grails I started to look for a DRY view for ruby when I found: http://github.com/codez/dry_crud I created a simple class class Capture include Mongoid::Document field :species, :type => String field :captured_by, :type => Str...

Why Ruby on Rails' Enumerable shows count of 3 but ".each" prints out item 1 time only

I have a Enumerable object returned from Mongoid (MongoDB object mapper) using HAML: = @employees.count = @employees.class - @employees.each do |e| =h e.inspect the count shows 3 the class shows Enumerable::Enumerator But only 1 item is printed out the object is returned in the controller using @employees = Employee.limit...

mongoid uniqueness validation many-to-many relation

I have following association class Employee include Mongoid::Document employee_id :name references_many :companies, stored_as => :array, :inverse_of => :employees end class Company include Mongoid::Document field :name references_many :employees, stored_as => :array, :inverse_of => :companies end Now How can I check the uni...

Does anybody have any tips for managing polymorphic nested resources in Rails 3?

in config/routes.rb: resources posts do resources comments end resources pictures do resources comments end I would like to allow for more things to be commented on as well. I'm currently using mongoid (mongomapper isn't as compatible with rails3 yet as I would like), and comments are an embedded resource (mongoid can't yet ha...

How do I implement a 'social' aspect with mongoid

I am attempting to create a friend network on a site I am making. I am using Mongoid. How do I instantiate friends? I assume that Users needs to have a relational association with multiple other users. But the following code: class User include Mongoid::Document references_many :users, :stored_as=>:array, :inverse_of=> :users en...

Using Mongoid, if we modify a single item, will it pull out a big chunk of data and save back a big chuck of data?

Supposed we have something using Mongoid: data: 'products': "2010-09-07": { pageviews: 123 timeOnPage: 1823 } "2010-09-08": { pageviews: 138 timeOnPage: 2607 } ... So 2, 3 years down the road, there will be 700 or 1000 dates mapping to a hash. If we modify 1 number, will it require readin...

Is it not good to use huge "documents" in MongoDB?

Since we can structure a MongoDB any way we want, we can do it this way { products: [ { date: "2010-09-08", data: { pageviews: 23, timeOnPage: 178 }}, { date: "2010-09-09", data: { pageviews: 36, timeOnPage: 202 }} ], brands: [ { date: "2010-09-08", data: { pageviews: 123, timeOnPage: 210 }}, { date: "2010-09-09"...