A controller extracts data from deeply nested associations where bilancino belongs_to :operativo which in turn belongs_to :cdg as such:
@cdgs = Cdg.order("id ASC").all
@bilancinos = Bilancino.joins(:operativo).order('cdg_id ASC').all
(with a where clause in there).
However when rendering
<% @cdgs.each do |cdg| %>
<% @cdgs_for_bilancino = @bilancinos.select{ |i| i.operativo.cdg_id == cdg } %>
<%= @cdgs_for_bilancino.each do |bilancino| %> XX <% end %>
<%= number_with_precision(@cdgs_for_bilancino.map(&:saldo).sum, :precision => 0, :delimiter => "\u00a0") %>
<% end %>
is generating an empty array, yet if underneath the following
<% @bilancinos.each do |bilancino| %>
<%= bilancino.operativo.cdg.conto %> <%= bilancino.saldo %><br />
<% end %>
will render. Thus the expression @bilancinos.select{ |i| i.operativo.cdg_id is missing the nested target somehow.
What is the proper syntax?
I suspect your issue is here:
For example, this is what I see in the console of one of my apps:
So try: