From: Raimon Fs Date: 2007-12-07T17:06:04+09:00 Subject: Re: array iterator that have more arrays that also need iter Xavier Noria wrote: > On Dec 7, 2007, at 12:13 AM, Raimon Fs wrote: > >> 1600_tax: "13210.85" >> >> >> I'm still getting attributes and values, not a simple array ... > > But why do you put a trace at that point? Of course a is a hash there, > but you are not aggregating the hash, you're collecting the > *collection of values of those hashes* via a.values. You need to work > with tha variable "values" which is assigned the result of the > map.chain. Please inspect the array stored in the variable "values" > after that block of code has run. Now I see where was my error ... I was using the variable a instead of variable values. Using the values gives me an array, but now I see that the order is not the expected. It's the same as it was in the hash, so the problem is at the begining, when I issue the sql: @temp_result = InvoicesCalcul.find_by_sql('SELECT sum(base) AS "'+ @name_base + '" ,sum(import) AS "' + @name_tax + '" ,sum(total_net) AS "' + @name_total + '" FROM invoices_calculs c, invoices i WHERE c.tipus='+KIND_TAX_IVA.to_s+' AND c.invoice_id=i.id AND c.xcent='+ @value +' AND i.any='+@c_year) I suppose, that @temp_result should be: --- - !ruby/object:InvoicesCalcul attributes: base: "707.59" tax: "0.0" total: "707.59" but it's: --- - !ruby/object:InvoicesCalcul attributes: tax: "0.0" total: "707.59" base: "707.59" so, I have to change my code, but at least, I learned how to extract the values from a hash and put in an array. Thanks, now is working, but I did some changes in other parts. regards, raimon -- Posted via http://www.ruby-forum.com/.