Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine MongoDB and Postgresql in Rails?

Is it possible to combine AR with MongoMapper/MongoID?

If so, are there tutorials/documentations for this?

like image 603
never_had_a_name Avatar asked Aug 24 '10 02:08

never_had_a_name


1 Answers

Yes, it is a piece of cake. There really isn't anything special you need to do, just make models with the different adapters accordingly. This is an example Mongoid document:

class Project
  include Mongoid::Document
end

For comparison, here is activerecord:

class BillingEntry < ActiveRecord::Base
end

Just make sure not to mix them up. For example, don't include mongoid on a class that inherits from ActiveRecord::Base. I recommend Rails 3, as it's probably going to release this week, and the RCs have been really solid so far.

like image 151
Preston Marshall Avatar answered Oct 02 '22 22:10

Preston Marshall