Hi there, I am dealing with a legacy database. We have 3 separate MySQL databases with identicle structure. We have one Rails Instance. based on the url: domain.com/one domain.com/two domain.com/three i need to use database one, two, or three respectivly. All the app files are identicle the only reason the databases are split is because the CMS had no way to separate the content between sites so they just used different databases. The database scema are rails friendly so i am using AR associations. My thought was to have a parent class (DbSwitch) that took an initialization parameter(site) and picked a db_config but I don''t think that will work for the find statments as i will have to pass an initialization param in the find. Item.new("one") is fine but how do i add the "one" to the item.find(:all) ? My other thought was to set an environment var per-user depending on the url and then just leave the app alone. Is that possible? Any sugestions would be greatly appriciated.... -- 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 -~----------~----~----~----~------~----~------~--~---
Michael Greenly
2006-Dec-12 01:06 UTC
Re: Dynamic database config based on url - possible?
Dinshaw Gobhai wrote:> Hi there, I am dealing with a legacy database. > We have 3 separate MySQL databases with identicle structure. > We have one Rails Instance. > > based on the url: > > domain.com/one > domain.com/two > domain.com/three > > i need to use database one, two, or three respectivly. >If at all possible it would seem a much more maintainable solution to run 3 rails intances, one for each cms. -- 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 -~----------~----~----~----~------~----~------~--~---
> If at all possible it would seem a much more maintainable solution to > run 3 rails intances, one for each cms.Thanks Michael. The other thought i had was if i could somehow read the request var inside the database.yml and do a switch. Does anyone knnow if there is a way to make evenironment vars available in database.yml? -- 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 -~----------~----~----~----~------~----~------~--~---