# Single table inheritance , how to alias the id key name?

**URL:** <https://www.ruby-forum.com/t/single-table-inheritance-how-to-alias-the-id-key-name/136935>\
**Category:** Rails\
**Created:** [May 7, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-how-to-alias-the-id-key-name/136935 "2008-05-07T15:28:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [May 7, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-how-to-alias-the-id-key-name/136935/1 "2008-05-07T15:28:24Z")

</div>

I have a model class Person \< ActiveRecord::Base  
and 2 classes inheriting from it  
class User \< Person and class Contact \< Person

obviously the id is person.id  
but is there anyway to use user.id and contact.id or should I  
always use person.id ???

thanks for your suggestions

erwin

---

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [May 7, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/single-table-inheritance-how-to-alias-the-id-key-name/136935/2 "2008-05-07T15:49:38Z")

</div>

On 7 May 2008, at 14:27, Erwin wrote:

> I have a model class Person \< ActiveRecord::Base  
> and 2 classes inheriting from it  
> class User \< Person and class Contact \< Person
> 
> obviously the id is person.id  
> but is there anyway to use user.id and contact.id or should I  
> always use person.id ???

Your question doesn’t really make a huge amount of sent. If foo is an  
instance of person, user, contact (or any other AR model for that  
matter) the foo.id gives you the primary key

Fred
