How to mix mongodb and a traditional db in Rails?

Jonathan picture Jonathan · Apr 21, 2010 · Viewed 7.4k times · Source

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?

Answer

MrKurt picture MrKurt · Apr 22, 2010

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.