简体   繁体   English

Rails应用程序+多个数据库实例

[英]rails application + multiple database instance

I need an idea to develop an webapplication using ruby on rails that can connect to to multiple database instances residing in single server.. 我需要一个使用ruby on rails开发Web应用程序的想法,该应用程序可以连接到驻留在单个服务器中的多个数据库实例。

I want to develop a webapplication and host it.. and connecting to database server... 我想开发一个Web应用程序并将其托管..并连接到数据库服务器...

now on different users on registering to the site, seperate database instance should be created for different users, each user details will be stored in their own database... 现在在不同的用户上注册该站点时,应该为不同的用户创建单独的数据库实例,每个用户的详细信息将存储在自己的数据库中...

Perticular user on logging in he should be connected to his database instance.. same case for other users.. 特定用户登录后应连接到他的数据库实例。其他用户也是如此。

please suggest a solution for this approach in both development and production.. 请为开发和生产中的这种方法提出解决方案。

It looks like you want to implement (some parts of) SaaS approach. 看起来您想实现SaaS方法(的某些部分)。 From the user side it looks like he gets clean working app for him only. 从用户方面看,他似乎只为他得到了干净的工作应用程序。 But apps are the same in a point of basic functionality and you want it to be the same app with different db instances. 但是在基本功能方面,应用程序是相同的,并且您希望它成为具有不同数据库实例的同一应用程序。 This approach has one significant minus - you can't customize your client's applications separately. 这种方法有一个很大的缺点-您不能单独自定义客户端的应用程序。

But you can redefine this class method of your models like this (only example): 但是您可以像这样重新定义模型的此类方法(仅示例):

self.table_name
  "#{current_user.name}_database.table"
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM