# Find 'joins'

**URL:** <https://www.ruby-forum.com/t/find-joins/172901>\
**Category:** Rails\
**Created:** [July 29, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/find-joins/172901 "2009-07-29T17:39:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 29, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/find-joins/172901/1 "2009-07-29T17:39:05Z")

</div>

I am very frustrated with :joins in a find.

@debts = Debtortranstaxes.find(:all,  
:conditions =\> [“trandate \> ? and trandate \<= ?”, @per1, @per2],  
:joins =\> ‘LEFT JOIN debtortrans ON debtortrans.id=debtortransid’,  
:order =\> ‘trandate, transno’)  
=\> [#\<Debtortranstaxes debtortransid: 67, taxauthid: 26, taxamount:  
0.63\>, #\<Debtortranstaxes debtortransid: 67, taxauthid: 34, taxamount:  
0.2\>, #\<Debtortranstaxes debtortransid: 68, taxauthid: 24, taxamount:  
3.15\>, #\<Debtortranstaxes debtortransid: 68, taxauthid: 32, taxamount:  
0.825\>, #\<Debtortranstaxes debtortransid: 69, taxauthid: 24, taxamount:  
756.0\>, #\<Debtortranstaxes debtortransid: 69, taxauthid: 32, taxamount:  
198.0\>]

but this does not contain the columns from debtortrans table…even if I  
specifically name them with a :select =\>

in the console, I can get the value  
@debts[0].trandate

but inside a loop, the value is not available to me…

for debt in @debts  
if debt.trandate = …

it simply tosses an undefined method error

How do I get all of the fields returned from joined tables in query?

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 30, 2009, 5:18am UTC](https://www.ruby-forum.com/t/find-joins/172901/2 "2009-07-30T05:18:39Z")

</div>

On Jul 29, 11:37 am, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 0.825\>, #\<Debtortranstaxes debtortransid: 69, taxauthid: 24, taxamount:  
> 756.0\>, #\<Debtortranstaxes debtortransid: 69, taxauthid: 32, taxamount:  
> 198.0\>]
> 
> but this does not contain the columns from debtortrans table…even if I  
> specifically name them with a :select =\>

The console is tricking you. if you name them they will be there,  
they’re just not displayed.

Fred.
