I appreciate that the layout that i''m using, described below, is
unusual and may seem downright stupid, but i''d like to get it working
because it has many advantages in the application i''ve designed (in
my mind those advantages outweigh the obvious disadvantages).
I have multiple sqlite databases, 1 per client, and a single base
application (using a derivation of the rails app productisation
method). All the databases have identical schemas and i''ve inserted a
piece of code into application.rb as a before_filter to make the
connection to the database which is relevant to the current connection.
ActiveRecord::Base.establish_connection(
:adapter => "sqlite",
:dbfile => "#{@site.docroot}/../db/data.db"
)
My problem is that, as soon as the application is switched into
production mode, the code to establish a new database connection is
ignored and only the database to which the first access was made is
used in subsequent connections. Presumably the fastcgi process is
holding open the first database connection (i''m a little unsure of
exactly what is happening behind the scenes).
Is there any way of forcing rails to drop any existing database
connections? I''ve tried remove_connection without success.
My platform is Lighttpd 1.4.8, SCGI_Rails 0.4.3 and Rails 14.2 all
running on Linux 2.6.
Any help would be much appreciated, its driving me mad!
Thanks
ben
p.s. i''m not particularly fussed about inefficiency, i have some
fairly chunky hardware to throw at this once its working! Version 2
is definately going to go down the single database route...