Reputation: 16359
I am considering using MongoDB (mongo-mapper) for a portion of my rails application. I am not ready to go whole hog MongoDB because there are too many useful gems that depend on a traditional DB.
That being said there are parts of my application that would be great to leverage a document database.
Has anyone had success mixing the two approaches? How do you link activerecord models with mongomapper models?
Upvotes: 20
Views: 7543
Reputation: 2375
Here a presentation about this issue: http://nosql.mypopescu.com/post/541657350/presentation-blending-nosql-and-sql-at-confoo
I don't know ROR so I can't judge it is a good presentation.
Upvotes: 3
Reputation: 1369
http://railscasts.com/episodes/194-mongodb-and-mongomapper http://www.mongodb.org/display/DOCS/Object+Mappers+for+Ruby+and+MongoDB http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails http://www.mongodb.org/display/DOCS/Ruby+Language+Center
You need to mixin mongomapper with the model class This gives you freedom to define the key-value pairs other than activerecord
include MongoMapper::Document
Dead simple I think.
Upvotes: 2
Reputation: 5100
MongoMapper doesn't implement ActiveModel yet, but I think there are a few forks on github that do. You could use Mongoid instead (which does) and your relationships between Mongoid docs and ActiveRecord entries would just magically work. I know a number of people are doing that.
That said, I wouldn't want to mix them unless I absolutely had to have an RDBMS for some reason.
Upvotes: 9