title: How can I force delayed_job to use a specific db connection?
body: <p>I have a Rails 3 applications that uses different databases depending on the subdomain. I do this by using "establish_connection" in the ApplicationController.</p>
  
  <p>Now I'm trying to use delayed_job gem to do some background processing, however it uses the database connection that it's active in that moment. It's connecting to the subdomain database.</p>
  
  <p>I'd like to force it to use the "common" database. I've done this for some models calling "establish_connection" in the model like this:</p>
  
  <pre><code>class Customer &lt; ActiveRecord::Base
    establish_connection ActiveRecord::Base.configurations["#{Rails.env}"]
    ...
  end
  </code></pre>
  
  <p>Any idea how can I do this?</p>