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
精彩评论