title: Rails ActiveRecord handle an id column that is not the primary key
body: <p>Struggling with ActiveRecord auto assigning the :id attribute as the primary key even though it is a separate column. </p>
  
  <pre><code>Table - legacy-table
  
      id - int
      pk_id - int (primary key)
      name - varchar2
      info - varchar2
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>class LegacyModel &lt; ActiveRecord::Base
    self.table_name = 'legacy-table'
    self.primary_key = 'pk_id'
    default_scope {order(:name =&gt; :asc)}
    alias_attribute :other_id, :id
  
  end
  </code></pre>
  
  <p>I don't care that ActiveRecord automatically assigns the primary key (pk_id) to the :id attribute however I lose all access to the actual id column.  Trying to use the alias simply points me back at the primary key.</p>
  
  <p>However one caveat to this issues is that from the view i can access the id column by using @legacymodel[:id].  But again when calling @legacymodel.id I get the value of the pk_id column.  What i want is to be able to call @legacymodel.other_id and have it point to the id column.  Instead @legacymodel.service_id, @legacymodel.id, and @legacymodel.pk_id all point to the same column pk_id </p>
  
  <p>Please note that this is a legacy db and modifying the columns are out of the question.  I am using Rails 4 with MySql.</p>
  
  <p>Is there anyway to code around this?  Why does @legacymodel[:id] give me different results then @legacymodel.id? </p>