Find 'joins'

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.

On Jul 29, 11:37 am, Craig W. [email protected] 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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs