# Find (ordering by field in related table)

**URL:** <https://www.ruby-forum.com/t/find-ordering-by-field-in-related-table/96214>\
**Category:** Rails\
**Created:** [June 27, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/find-ordering-by-field-in-related-table/96214 "2006-06-27T12:08:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [June 27, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/find-ordering-by-field-in-related-table/96214/1 "2006-06-27T12:08:02Z")

</div>

Hi,

I am using the rails find command as below

@project\_pages, @projects = paginate :projects, :per\_page =\> 20,  
:conditions =\> "clients.organisation\_id = " +  
params[‘search’][‘organisation\_id’],  
:joins =\> ‘inner join clients ON clients.id = projects.client\_id’

There seems to be a problem with project.id being over written with  
project.client.id.

Any suggestions to whats going wrong?

Thanks  
scott

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [June 27, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/find-ordering-by-field-in-related-table/96214/2 "2006-06-27T12:33:40Z")

</div>

solved by doing

@project\_pages, @projects = paginate :projects, :per\_page =\> 20,  
:conditions =\> "clients.organisation\_id = " +  
params[‘search’][‘organisation\_id’],  
:include =\> [:client]
