[Rails] Swapping DBs based on subdomains
Williams, Chris
Chris.Williams at xeroxlabs.com
Tue Mar 1 14:44:56 GMT 2005
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
More information about the Rails
mailing list