Home Rails 使用多数据库multipledatabases
Post
Cancel

Rails 使用多数据库multipledatabases

这个超级简单。

Rails4 中需要参考:  https://stackoverflow.com/questions/28485137/multiple-database-connection-in-rails-4/28490913

1. config/database.yml 中,增加第二个数据库配置

second_production: ...

2.  在对应的model中,增加:

connect_to "second_production"... 

就可以了。

具体谷歌一下。。。TODO 回头把完整代码补充上来。

This post is licensed under CC BY 4.0 by the author.