2012-07-04 49 views
2

让我们说,我们在我们的应用程序以下型号:指向AR模型的Mongoid模型,反之亦然?

# AR model 
class Foo < ActiveRecord::Base 
    belongs_to :bars # this is an association pointing to a Mongoid model 
end 

# Mongoid model 
class Bar 
    include Mongoid::Document 
    belongs_to :foo # this is an association pointing to a AR model 
end 

是否有可能创建一个指向AR模型,反之亦然Mongoid模型的关联?

+2

通过这些可能会帮助http://stackoverflow.com/questions/7026981/mongoid-and-activerecord-relations-undefined-method-quoted-table-name和这一个http://stackoverflow.com/questions/4090768/activerecord-and-mogoiddocument-associations – abhas

回答

2

我们对此使用Tenacity(也称为“Polyglot Persistence”)。它工作得很好,但有一些限制。所有者/维护者JWood的响应速度非常快,并且修复了错误,并在我发送非常迅速的请求中合并。

+0

+1,这就是我现在使用的。我忘了提交我自己的答案。 –