On Wed, Nov 20, 2013 at 8:52 AM, Paulo Henrique Leite de Castro
<[email protected]> wrote:

> prepend_before_filter :database_connection
>
> and this method has the following code:
>
> ActiveRecord::Base.establish_connection({:adapter => "mysql", :database =>
> "#{current_user.dbname}", :username => "x", :password => "x", :host => "x",
> :encoding => "utf8"})
>
> So, for each request I get the current authenticated user database name and
> set the connection to customer database.

I would wonder how this plays with connection pooling. In any case,
since you're explicitly opening the connection, I'd add an after_filter
to explicitly *release* the connection after using it.

And it might be worth testing whether setting the connection pool
size to 1 changes the behavior. Not that that's necessarily a great
long-term "solution", but for troubleshooting purposes. :-)

HTH,
-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBtDQuA7YL2hYA4f09b0sjkZFuO%3DX9yAkfoZZTmpAne0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to