mongomapper

how to put embedded document into an embedded document ?

hi I have a form that has a category model and and embeded docuement called "FieldModule" and this has embedded document called "SubFieldModule" For example class Category include MongoMapper::Document key :name, String many :field_modules end class FieldModule include MongoMapper::EmbeddedDocument key :name, String ...

Ruby on Rails fails to connect to Mongodb locally using MongoMapper

Hey, I'm very new to rails and have been trying to experiment with using Mongodb on a web app. I have been following this railscast tutorial here word for word and have been running into issues with it not connecting to my local Mongodb. I'm sure Mongodb is up and running since mongod shows up in my activity monitor and going to ht...

Are there any good documents for mongo_mapper?

After some searches, I found the documentation of mongo_mapper is poor. There is only a short readme on GitHub, only one article in http://mongomapper.com, and just a list of classes in the RDoc. I know there is a good screencast at http://railscast.com, but I want some more good documents about how to using mongo_mapper. Are there an...

Problem creating more than one Rails app using MongoDB

I properly installed MongoDB and got it running on my OSX. The first app I created using MongDB and Rails3 was titled 'todo". Per the instructions on railscasts, I created a file (config/initilializers/ mongo.rb) and added this line: MongoMapper.database = "todo- #{Rails.env}" Presumably, this created the files that appeared in my ...

Update mongodb document without updating embedded document and vice versa

Hi I have a document with an embedded document in it. I have 2 forms, 1 that updates fields in document and one that updates fields in emdedded docs. They are split into 2 forms as lots of fields in each etc and actually this is just a simple example of the structure of my app. Everywhere else that i reference this data it makes m...

Ruby MongoMapper Question about Mapping

I have a MongoDb database called Northwind. The database was created using C# driver. It contains 10-20 rows. Now, I want to get all those rows out from Ruby. I am using MongoMapper but how can I map a Ruby class "Category" to the "Name" field in the document. require 'mongo_mapper' class Category include MongoMapper::Document key :...

Rethinking relational many-to-many relationships for MongoDB

I am just starting a new Rails 3 project using Mongoid ORM for MongoDB. There is just one thing I can not get my head around, and that is how to effectively have a many-to-many relationship. Now there is a good chance that I may be approaching this problem wrong, but as far as I know, there is at least two containers in my project that...

How do I get cucumber and pickle working with mongo_mapper, machinist, and machinist_mongo?

I would like to get machinist, machinist_mongo, mongo_mapper, cucumber and pickle to play nice together. Currently I have machinist with all my blueprints configured and am using cucumber to do BDD. So far so good. My problem is I am having to write custom cucumber steps for all of my machinist blueprints. It is not really a problem per...

mongodb find in embedded document hash mongomapper

hi I have a menu class and that have many menu_items and a menu_item class that is embedded docuemnt. I can get a specific menu like menu = Menu.find_by_name("menu 1") then i want to find and update or create the menu_item that matches a specific category id. I want to create the menu item if category id is not found in menu items...

MongoMapper Embedded Documents

I have products as an embedded document inside the category class as shown below: require 'mongo_mapper' class Category include MongoMapper::Document key :Name, String key :NumberOfProducts, Integer many :products end and here is the Product class: require 'mongo_mapper' class Product include MongoMapper::EmbeddedDocument ...

Create rails locale yaml file automatically ?

hi is it possible to create / update a locale language yaml file from with a rails application ? If so is would it be automatically pulled into the load path somehow as i dont want to have to restart to pull in the new changes ? Is this possble and if so how ?? or is there a better way ? I am using mongodb as a db. thanks rick ...

Mongomapper/mongoDB: SystemStackError: stack level too deep

I have a Rails 3 model "D" that belongs to another model, which belongs to another two in turn, like this: D belongs to C C belongs to B B belongs to A I am using MongoDB/Mongomapper as my ORM. When I try to instantiate D, I am getting an error: ruby-1.9.2-preview3 > d = D.new SystemStackError: stack level too deep from /Users/peter...

Mongodb , rails modify non-array - debug kind_of? Array >> true

I've been trying to add to an array (or what ruby is saying is an array), but keep getting an error from mongo which says Cannot apply $addToSet modifier to non-array when I try to run User.collection.update({'id'=> current.id},{'$addToSet'=>{ 'following' => current.id}}) User.collection.update({'id'=> user.id},{'$addToSet'=...

Paperclip with MongoMapper in Rails 3

I'm trying to implement Paperclip in my first rails app, and I happen to be using rails 3 and mongodb with mongomapper. I followed this guide on getting there things to all work together http://www.bencurtis.com/2009/08/paperclip-and-mongomapper/ Just as the blog post suggests, I've put paperclip into the config/initializers directory,...

MongoDB and Authlogic, any gotchas? (mongomapper)

Authlogic, by itself, seems to be too active record centric for MongoDB (specifically mongomapper) as per: http://github.com/binarylogic/authlogic/issues#issue/15. However, there's an interesting authlogic plugin for mongo that looks pretty awesome, and simple. Has anyone used this, or have any experience/recommendations for an authlo...

MongoMapper docs

Does anyone have a good resource for MongoMapper documentation? I've been reading through the mongoDB docs, but a lot of it doesn't convert across to ruby/mm. I've been trying to figure out how to do a SELECT FROM WHERE EXISTS with little success. db.things.find( { a : { $exists : true } } ); // return object if a is present The only ...

mongodb gridfs carrierwave or joint or other ?

i want to store all my assets in mongo gridfs. i was trying to get carrierwave setup with mongomapper and gridfs but seems carrierwave supports mongoid now instead. I need to be able to save different size versions / cropped versions of an image so thats why i was going to use carrierwave. Currently its set up to store on file ...

MongoMapper - manually setting an ObjectId failing with "illegal ObjectID format"

I've got a simple model object: class UserRating include MongoMapper::EmbeddedDocument key :idea_id, ObjectId key :rating, Integer end I'm trying to set an Idea_Id on this object with: user_rating.idea_id = ObjectId.new This throws: "illegal ObjectID format" This sure seems like simple code... The only oddity I am noticing ...

querying object in rails (no activeRecord, using mongo with mongomapper)

I've got a group of messages in mongo which I am retrieving in rails with @messages = current_user.user_messages(@user) I now want to select the number of messages which were created in the last week, so I thought I could take the @messages and query that directly with @countRecent = @messages.count(:conditions => {:created_at =>{'$...

How to set up MongoMapper associations with complex conditions?

I'm trying to put together an association that takes advantage of Mongo's document subkey indexing. For example, I have two collections, posts and topics. Posts have a tags key, which is an indexed set of tags for the post - pretty vanilla. What I want to do though, is have something in my Topic model like: class Topic key :name, Stri...