简体   繁体   中英

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..

I want to develop a webapplication and host it.. and connecting to database server...

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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