5

Is it possible to combine AR with MongoMapper/MongoID?

If so, are there tutorials/documentations for this?

2
  • Yes it's possible. Can you please be more specific on what you want to achieve? Commented Aug 24, 2010 at 5:11
  • There's another question that might provide some insight (and who knows, even answer!): stackoverflow.com/questions/2258681/… Commented Aug 27, 2010 at 18:28

2 Answers 2

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

does this still work? I'm using rails 4. Just install mongoid gem and put that one line include Mongoid::Document in for example my model and done?
Looks like that much is the same. Check out the docs here: mongoid.org/en/mongoid/index.html
1

Yes it's possible. Can you please be more specific on what you want to achieve? It's even easier if you use Rails 3 because mongoid and ActiveRecords uses ActiveModel as the interface.

1 Comment

I want to use MongoDB with MongoID for my content data and Postgresql with ActiveRecord for ACID-crucial customer/billing data. Are there tutorials how to combine them? I'm pretty new on Rails.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.