R
Raimon Fs
Hello ...
In my new introduction to RoR and Ruby, I'm stopped again ...
I know it must be easy, but I can't figure it out, maybe I'm stucked ...
I have one array, and each element of this array, has another array.
I have to loop over two arrays, and extracting all the values, without
knowing their attributes ...
I tried with array.each, array.each_index, ...
here is may array dumped:
- - !ruby/object:InvoicesCalcul
attributes:
1600_base: "82567.36"
1600_value: "95778.21"
1600_tax: "13210.85"
- - !ruby/object:InvoicesCalcul
attributes:
700_tax: "17.91"
700_base: "255.81"
700_value: "273.72"
- - !ruby/object:InvoicesCalcul
attributes:
0_base: "707.59"
0_tax: "0.0"
0_value: "707.59"
I need:
82567.36 95778.21 13210.85
17.91 255.81 273.72
707.59 0.0 707.59
and here is the last I tried ...
the dumped array is: @arr
the @arr_tax is another array, but this works
what I'm getting is the object or something strange, no errors.
<%@arr.each_index{|x| %>
<tr>
<td align=Right width="50px"> (x<%= x%>) <%= @arr_tax[x]%></td>
<%@arr[x].each{|y| %>
<td align=Right>(y<%= y%>) <%= y[x]%></td>
<% }%>
</tr>
<% }%>
thanks!
raimon
In my new introduction to RoR and Ruby, I'm stopped again ...
I know it must be easy, but I can't figure it out, maybe I'm stucked ...
I have one array, and each element of this array, has another array.
I have to loop over two arrays, and extracting all the values, without
knowing their attributes ...
I tried with array.each, array.each_index, ...
here is may array dumped:
- - !ruby/object:InvoicesCalcul
attributes:
1600_base: "82567.36"
1600_value: "95778.21"
1600_tax: "13210.85"
- - !ruby/object:InvoicesCalcul
attributes:
700_tax: "17.91"
700_base: "255.81"
700_value: "273.72"
- - !ruby/object:InvoicesCalcul
attributes:
0_base: "707.59"
0_tax: "0.0"
0_value: "707.59"
I need:
82567.36 95778.21 13210.85
17.91 255.81 273.72
707.59 0.0 707.59
and here is the last I tried ...
the dumped array is: @arr
the @arr_tax is another array, but this works
what I'm getting is the object or something strange, no errors.
<%@arr.each_index{|x| %>
<tr>
<td align=Right width="50px"> (x<%= x%>) <%= @arr_tax[x]%></td>
<%@arr[x].each{|y| %>
<td align=Right>(y<%= y%>) <%= y[x]%></td>
<% }%>
</tr>
<% }%>
thanks!
raimon