<p>I'd like the canonical way to do this.  My Google searches have come up short.  I have one ActiveRecord model that should map to a different database than the rest of the application.  I would like to store the new configurations in the database.yml file as well.</p>

<p>I understand that establish_connection should be called, but it's not clear where.  Here's what I got so far, and it doesn't work:</p>

<pre><code>class Foo &lt; ActiveRecord::Base
    establish_connection(('foo_' + ENV['RAILS_ENV']).intern)
end
</code></pre>

Heh.  I was right!  More cleanly:
```
```
class Foo < ActiveRecord::Base
    establish_connection "foo_#{ENV['RAILS_ENV']}"
end
```
```
Great post
at pragedave.pragprog.com
.