# Different id\_field

**URL:** <https://www.ruby-forum.com/t/different-id-field/164648>\
**Category:** Ruby\
**Created:** [April 3, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/different-id-field/164648 "2009-04-03T17:13:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sushrut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@sushrut](https://www.ruby-forum.com/u/sushrut)\
**Post date:** [April 3, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/different-id-field/164648/1 "2009-04-03T17:13:25Z")

</div>

Hi,  
In my table there is no id field,i.e. I have the field with the name  
id\_host  
then how to use that field in my application without changing the field  
name.

---

<div class="post-metadata">

**Author:** ![sushrut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@sushrut](https://www.ruby-forum.com/u/sushrut)\
**Post date:** [April 4, 2009, 12:45am UTC](https://www.ruby-forum.com/t/different-id-field/164648/2 "2009-04-04T00:45:26Z")

</div>

Hi,

On Apr 3, 2009, at 10:12 AM, Sushrut S. wrote:

> Hi,  
> In my table there is no id field,i.e. I have the field with the name  
> id\_host  
> then how to use that field in my application without changing the  
> field  
> name.

Assuming you mean Rails, you may have better luck next time asking on  
their list. Try this:

class ModelName \< ActiveRecord::Base  
set\_primary\_key “id\_host”  
end

- Stephen
