Rails 3:如何同时使用active record和mongoid
我读到很多人建议将 nosql 与 sql 数据存储一起使用。例如,在 mysql 中有一些报告审计跟踪或日志信息,在 mongodb 中有一些线程分层数据。
是否可以将 Rails 与 mysql 和 mongoid 上的活动记录连接起来?
开箱即用似乎不起作用......有什么提示吗? 或者这是一个不推荐的方法?
I read alot that folks recommend using nosql together with sql datastores. For example have some reporting audit-trailing or log information in mysql and some threaded hierarchical data in mongodb.
Is it possible to hook up rails with active record on mysql as well as mongoid?
Out of the box it seems not to work...Any hints?
Or is this a not recommended approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,要做到这一点,您应该保持 Rails 完好无损,因此不要像 Mongoid 文档中通常建议的那样排除库。您需要单独配置它们,因此您需要有一个database.yml和mongo.yml配置文件,并且需要确保它们都被加载。
之后,您可以针对每个模型启用/禁用 AR 和 Mongoid。
Well, to do it, you're supposed to leave Rails intact, so don't exclude libraries like it's commonly suggested in Mongoid documentation. You need to configure them separately, so you need to have a database.yml and mongo.yml config files and you need to make sure they're both getting loaded.
After that, you can enable/disable AR and Mongoid on a per-model basis.