Hi All: I want my application to authenticate user through master database and accordingly should connect them to their specific database. I am using the sub-domain as identifier for the user and stores domain-database information in master database. Im using a function responsible for mapping domains to database in application.rb using before_filter :function_call Default database will be master and function will identify the user specify db to establish a connection at runtime. The problem is ..the next time i tries to logout and use different domain.. it still uses previous database and tries to find domain-database related information there, which actually is in masters. Plz suggest me some way to it. Thanks in Advance Priya Saini -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I assume that your initial case is working: New web session hits the web server, application sees "new" and uses master database. User logs in (verified against master) and is hooked up to the correct database. Not knowing any of the details of your login/logout or session management, it sounds like after logging out, you aren''t clearing enough data out of the session so that the same browser session would be recognized as "new" (i.e., the same as a totally new browser session) when you try to log back in. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Chron: Thanks for the reply. Yes the initial case is working but there is something to be decided there as well. In application.rb i use before_filter :switch_db def switch_db @db = Client.find_by_domain_name(request.env[''HTTP_HOST'']) db_name = @db.database_name ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "", :username => "", :password => "", :database => db_name, :port => "3333" ) end Initially it selects the db well but since application.rb is called always the function gets executed each time and tries to find client in the current db. What condition shall be placed to by pass this function if there already exists a database connection [other than with master]. Regards, Priya Saini -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think on logout i have to end the current db connection. How can i do this?? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Not to backtrack too far, but why a separate physical database per user? If they are all running the same application, could not a single database be used for multiple users? You''d just need to scope the queries by "owner", and persist the owner on record creation. To answer your question, "disconnect!" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ar Chron wrote:> Not to backtrack too far, but why a separate physical database per user? > > If they are all running the same application, could not a single > database be used for multiple users? You''d just need to scope the > queries by "owner", and persist the owner on record creation. > > To answer your question, "disconnect!"Hi Chron: I am planning to keep seperate db for all my future clients coz keep a single db wont be feasible since they may have their individual requirements and configuration. Also we have Ferret Search in our application.. so keep dbs seperate will be a better option. Anyways i did it. I maintained a session variable to avoid function call each time. N thanks for "disconnect!" :) What i am lookin for now is how to maintain two db connections simultaneously and how to hop among them. I dont want to set up connection each time i need it. Thanks Again Priya Saini -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---