title: Rails 3.2 multiple database connections with same model name
body: <p>There are many questions and answers regarding the creation of multiple connections to multiple databases in rails: </p>
  
  <p><a href="https://stackoverflow.com/a/7480330/2120023">https://stackoverflow.com/a/7480330/2120023</a></p>
  
  <p><a href="https://stackoverflow.com/a/6305540/2120023">https://stackoverflow.com/a/6305540/2120023</a></p>
  
  <p>Example from outside stackoverflow: <a href="http://ilikestuffblog.com/2012/09/21/establishing-a-connection-to-a-non-default-database-in-rails-3-2-2/" rel="nofollow noreferrer">http://ilikestuffblog.com/2012/09/21/establishing-a-connection-to-a-non-default-database-in-rails-3-2-2/</a></p>
  
  <p>But I have yet to find a solution that works when using a model that appears in both databases.</p>
  
  <p>If my default db has a table <code>titles</code> and my <code>Other</code> db has a table <code>titles</code> how do I access the other database's Title model?</p>
  
  <p><code>title.rb</code>:</p>
  
  <pre><code>class Title &lt; ActiveRecord::Base
  end
  </code></pre>
  
  <p><code>othertitle.rb</code>:</p>
  
  <pre><code>class Other &lt; ActiveRecord::Base
    self.abstract_class = true
    establish_connection "other_#{Rails.env}"
  end
  
  class OtherTitle &lt; Other
  end
  </code></pre>
  
  <p>I can't use the above because I get this error (EDIT: for clarity there is no <code>other_titles</code> table in either db only a <code>titles</code> table -> EDIT 2: If I do create an <code>other_titles</code> table in the <code>Other</code> database, everything works perfectly but that does not help me access the <code>titles</code> table.):</p>
  
  <pre><code>ActiveRecord::StatementInvalid: Mysql2::Error: Table 'other.other_titles' doesn't exist: SHOW FULL FIELDS FROM `other_titles`
  </code></pre>
  
  <p>I also can't use <code>class Title &lt; Other</code> because I get a <code>TypeError: superclass mismatch for class Title</code> error.</p>
  
  <p><code>database.yml</code></p>
  
  <pre><code>development:
    adapter: mysql2
    encoding: utf8
    database: db_dev
    pool: 5
    username: xxxx
    password: xxxx
    socket: /var/lib/mysql/mysql.sock
  
  production:
    adapter: mysql2
    encoding: utf8
    database: db
    pool: 5
    username: xxxx
    password: xxxx
    socket: /var/lib/mysql/mysql.sock
  
  
  other_development:
    adapter: mysql2
    encoding: utf8
    database: other_dev
    pool: 5
    username: xxxx
    password: xxxx
    socket: /var/lib/mysql/mysql.sock
  
  other_production:
    adapter: mysql2
    encoding: utf8
    database: other
    pool: 5
    username: xxxx
    password: xxxx
    socket: /var/lib/mysql/mysql.sock 
  </code></pre>