在 Rails 2.3.6 上运行 MongoDB 和 Mysql
在 Rails 2.3.6 中,我尝试在同一应用程序上通过 MongoMapper 和 Mysql 使用 MongoDb。
我已经看到其他几个与此相关的问题,但我找不到如何配置 Rails 以在同一应用程序中使用这两个数据库。
我应该如何配置我的database.yml 文件? 现在是:
development:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_rails_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_rails_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
我应该添加一些初始化程序吗?
提前致谢, 奥古斯托
In Rails 2.3.6 I'm trying to use both MongoDb via MongoMapper and Mysql on the same application.
I've seen several others question about this but I cannot find how to configure rails to use both database in the same app.
How should I configure my database.yml file?
Right now it is:
development:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_rails_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql
encoding: utf8
reconnect: false
database: blinddog_rails_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
Should I add some intializers?
Thanks in advance,
Augusto
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,您将使用活动记录和标准database.yml 文件。您还可以运行 Rails g mongo_mapper:config 来创建 mongo.yml 文件。它们是独立的,应该允许您在模型中使用它们。这也适用于 mongoid。
So you would use active record and standard database.yml file. You would also run rails g mongo_mapper:config to create your mongo.yml file. These are seperate and should allow you to use both in your model. This would work for mongoid too.