tk schrieb:> Hi
>
> I''m completely new to RoR and don''t know how to exactly
achieve the
> following task:
> With our old web app we switched the database depending on the domain
> name so that we could use one application for multiple customers:
>
> > xy.com > Database Xy
> > yz.com > Database Yz
>
> This changed the database at the beginning of each visitor/users
> session. Is something like this achievable with RoR?
>
> Thanks.
>
>
> >
>
there are a few options, but ultimately you''ll need to...
YourModel.establish_connection(
:adapter => mysql,
:host => localhost,
:username => xyz,
:password => password,
:database => params[''dbinfo'']
)
Where *params[''dbinfo'']* is the variable containing your
database name.
this will set the connection to whichever database you need. You won''t
(I don''t think) be able to do this within the model class.
You''ll have
to do it in a controller. Although you might want a default setting in
the model class, for console work and such.
/ak
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---