# Connecting model class to different column name other tn id

**URL:** <https://www.ruby-forum.com/t/connecting-model-class-to-different-column-name-other-tn-id/164651>\
**Category:** Rails\
**Created:** [April 3, 2009, 5:44pm UTC](https://www.ruby-forum.com/t/connecting-model-class-to-different-column-name-other-tn-id/164651 "2009-04-03T17:44:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav\_darji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vaibhav\_darji](https://www.ruby-forum.com/u/vaibhav_darji)\
**Post date:** [April 3, 2009, 5:44pm UTC](https://www.ruby-forum.com/t/connecting-model-class-to-different-column-name-other-tn-id/164651/1 "2009-04-03T17:44:15Z")

</div>

wrote:  
I am using the allready created tables in oracle and connecting to the  
ruby on rails model class, i used 'set\_table\_name ‘table name’ ’ and it  
gets connected but, i want to access its records and it has different id  
field name as field\_id, i want to access its record making field\_id  
field as my id field so that i can access its records but i dont want to  
rename field\_id to id sence, it has laks of records and my company is  
using those records can any one sugust me the way to connect the model  
to field\_id column…plz help

Thanks in advance…  
with regards,  
vaibhav

---

<div class="post-metadata">

**Author:** ![vaibhav\_darji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vaibhav\_darji](https://www.ruby-forum.com/u/vaibhav_darji)\
**Post date:** [April 4, 2009, 6:23am UTC](https://www.ruby-forum.com/t/connecting-model-class-to-different-column-name-other-tn-id/164651/2 "2009-04-04T06:23:57Z")

</div>

Use the set\_primary\_key method.

---

<div class="post-metadata">

**Author:** ![vaibhav\_darji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vaibhav\_darji](https://www.ruby-forum.com/u/vaibhav_darji)\
**Post date:** [April 4, 2009, 11:10am UTC](https://www.ruby-forum.com/t/connecting-model-class-to-different-column-name-other-tn-id/164651/3 "2009-04-04T11:10:40Z")

</div>

Siddick E. wrote:

> Use the set\_primary\_key method.

I used this method as follows

class Item \< ActiveRecord::Base  
set\_table\_name ‘item’  
set\_primary\_key ‘id\_field’  
end

and now its working properly,  
Thanks you,  
for your good response!!!  
Keep responding me…
