RE: Swapping DBs based on subdomains

Williams, Chris
2005-03-01T14:44:56Z

Chris,


> http://wiki.rubyonrails.com/rails/show/HowToUseSubdomainsAsAccountKeys
>
> and
>
> http://wiki.rubyonrails.com/rails/show/HowtoUseMultipleDatabases
>
> Might help you
>
> Chris

Thanks, they did help. Just to share information for everyone, I kept
running into problems using the examples verbatim. I inserted the
hijack_db method and before_filter into my application controller. The
problem was that I also do authentication and carry a User object in the
session. So I was forced to include "model :user" inside the
application
controller. This caused Rails to barf if I didn''t have a connection set
up.

So what I had to do was stick the users table in the DB for my
environment (if I stuck to the config DBs). Its ugly, but it works. So I
always hijack the DB before anything important happens, but I do need to
provide tables for model objects carried in the session in the DB setup
by database.yml.

Thanks,
Chris