title: Rails 4 - Pull data from external MySQL
body: <p>I'm trying to connect external MySQL database into <strong>Rails 4</strong> and read data from there. So what i did so far:</p>
  
  <ul>
  <li>Create in <code>lib/primo_db.rb</code></li>
  <li>Create model <code>models/accountstatus.rb</code></li>
  </ul>
  
  <p><strong>primo_db.rb</strong></p>
  
  <pre><code>require 'active_record'  
  require 'mysql'
  
  class PrimoDatabase &lt; ActiveRecord::Base
    self.abstract_class = true
    establish_connection(
    :adapter  =&gt; 'mysql',
    :database =&gt; '...',
    :host     =&gt; '...',
    :username =&gt; '...',
    :password =&gt; '...'
    )
  end
  </code></pre>
  
  <p><strong>account.rb</strong></p>
  
  <pre><code>require 'primo_database'
  
      class Account &lt; PrimoDatabase
          self.table_name = 'account'
          def self.getdata
  
          end
      end
  </code></pre>
  
  <p><strong>And my question is:</strong></p>
  
  <ul>
  <li><p>How to test connection in console between them because when i run <code>Accountstatus.getdata</code> in rails console i get this error <code>NameError: uninitialized constant PrimoDatabase</code></p></li>
  <li><p>And if i run <code>ActiveRecod::Base.connection?</code> it's returning <code>false</code></p></li>
  </ul>
  
  <p>I know that I'm doing something wrong so I'll appreciate any help with that.</p>
  
  <p><strong><em>EDITED - SEE THE ANSWER TO UNDERSTAND WHAT I DID BELOW</em></strong></p>