2

I am have a application where the user can chose the database which they to access. I have to authenticate the user which the database they have chosen and i have to keep the transaction with thr user and the database till the user logs out.

I was able to do it by establish_connection and passing the database name requested by the user. But i hit a roadblock.The issue is,

Lets assume user1 requested to access the databaseA and the user has got the access not logged out,If user2 requests to access databaseB , In that case even the user1's requests are hitting to DatabaseB

I am aware that Devise can solve this problem, I am not able to figure it out how.

Any suggestions would be really helpful

user2914486
  • 163
  • 1
  • 15
  • Post-authentication, will user access any other data? Are those data coming from same DB for all users or user-selected-DB for a given user? – Wand Maker Feb 04 '16 at 19:33
  • Yes, Post authentication the user will access the data .For a given user, The data will be fetched from the user-selected DB – user2914486 Feb 05 '16 at 02:24
  • Possible duplicate of [Multiple databases in Rails](http://stackoverflow.com/questions/1825844/multiple-databases-in-rails) – Wand Maker Feb 05 '16 at 04:02
  • Your problem is not limited to only `Devise` then. Look at possible duplicate question [Multiple database in Rails](http://stackoverflow.com/questions/1825844/multiple-databases-in-rails) – Wand Maker Feb 05 '16 at 04:03
  • @WandMaker Thaks for the feedback... I was able to connect to multiple DB using magic multi connection , Below is the article, http://magicmodels.rubyforge.org/magic_multi_connections/ But, I have to accomodate this change in devise ,But Devise always takes the default database ..Can you please help me out with this. – user2914486 Feb 08 '16 at 06:09
  • Not really a user of devise, may not be able to point to a solution currently – Wand Maker Feb 08 '16 at 10:42

0 Answers0