# Get an object other than primary key ID

**URL:** <https://www.ruby-forum.com/t/get-an-object-other-than-primary-key-id/152208>\
**Category:** Rails\
**Created:** [October 31, 2008, 9:24am UTC](https://www.ruby-forum.com/t/get-an-object-other-than-primary-key-id/152208 "2008-10-31T09:24:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthik\_chigurupati](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9d8465/32.png) [@karthik\_chigurupati](https://www.ruby-forum.com/u/karthik_chigurupati)\
**Post date:** [October 31, 2008, 9:24am UTC](https://www.ruby-forum.com/t/get-an-object-other-than-primary-key-id/152208/1 "2008-10-31T09:24:35Z")

</div>

Hello,  
i want to retrieve and object from a table other than primary  
key ID.

eg: @sites.each do |@site|  
@site\_id = @site.id  
@tower = Tower.find(:all, :conditions =\> [“site\_id =?”,  
@site\_id])

Tower Belongs to Site. so Site\_id is a reference in tower object.  
there will be only one Tower object for Site Object.

Should we give relation as has\_obne in site model??

help me ot.

Karthik
