ActiveRecord的和蒙戈/蒙戈映射器桥 [英] activerecord and mongo / mongo-mapper bridge

查看:194
本文介绍了ActiveRecord的和蒙戈/蒙戈映射器桥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我已经使用的Active Record和我想添加使用MongoDB的一些新功能的项目。而不是重新发明轮子,重新写我的整个网站,我怎么能整合2车型一起,其中一个用MongoMapper和其他的ActiveRecord(Postgres的)。

I have a project which I have used Active Record and which I'd like to add some new features using MongoDB. Rather than re-invent the wheel and re-write my entire site, how can I integrate 2 models together, one which use MongoMapper and the other ActiveRecord (postgres).

我发现,别人已经成功地做​​到了,但没有例子:

I've found that others have done it successfully, but no examples:

<一个href="http://groups.google.com/group/mongomapper/browse_thread/thread/ec5ad00e18e7dd2c/887b8b0b904a8f73?lnk=gst&q=activerecord#887b8b0b904a8f73" rel="nofollow">http://groups.google.com/group/mongomapper/browse_thread/thread/ec5ad00e18e7dd2c/887b8b0b904a8f73?lnk=gst&q=activerecord#887b8b0b904a8f73

例如,我有我想涉及到地点的现有ActiveRecord模型......即城市的地方性病蒙戈模式(S)。基于Authlogic用户模型......我该如何使用他们的演唱会?我很感谢两个在正确的方向指针。

For example, I have an STI Mongo model(s) of Places which I want to relate to an existing ActiveRecord model of Locations... ie Cities. and a User model based on Authlogic... how can I use them in concert? I'd be grateful for a pointer or two in the right direction.

谢谢

推荐答案

这美丽的工作。

  key :location_id, Integer, :required => true

    def location
        Location.find(location_id)
    end

位置模式

  def self.find_places(id)
    Property.find_by_location_id(id)
  end

  def find_places
    Property.find_by_location_id(id)
  end

这篇关于ActiveRecord的和蒙戈/蒙戈映射器桥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆