Rails中的多个数据库 [英] Multiple databases in Rails
问题描述
这样做可以吗?在单个应用程序中,它使用SQLite管理许多项目。
我想要的是为我的应用程序正在管理的每个项目有一个不同的数据库。因此,一个相同结构的数据库的多个副本,但在其中有不同的数据。我将选择使用基于URI上的params的副本。
这是为1.安全。我是一个新的在这种编程我不希望它发生,因为某些原因,当工作在一个项目,另一个被破坏.. 2.容易备份和归档的旧项目
默认情况下,Rails不是为多数据库架构而设计的,在大多数情况下,它根本没有意义。
但是,您可以使用不同的数据库和连接。
以下是一些参考:
- ActiveRecord:连接到不同模型中的多个数据库
-
- Ruby on Rails中的多个数据库连接
- Magic Multi-Connections
- ActiveRecord: Connection to multiple databases in different models
- Multiple Database Connections in Ruby on Rails
- Magic Multi-Connections
Can this be done? In a single application, that manages many projects with SQLite. What I want is to have a different database for each project my app is managing.. so multiple copies of an identically structured database, but with different data in them. I'll be choosing which copy to use base on params on the URI.
This is done for 1. security.. I'm a newbe in this kind of programming and I don't want it to happen that for some reason while working on a Project another one gets corrupted.. 2. easy backup and archive of old projects
Rails by default is not designed for a multi-database architecture and, in most cases, it doesn't make sense at all. But yes, you can use different databases and connections.
Here's some references:
这篇关于Rails中的多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!