@customer.deliveries.count give 5 while the table has 6 lines.
Why?
I think it's all ok but I cannot undestand why the each cycle give me
one more line in the table.
No no, including the header I have a total of 7 rows.
If @customer.deliveries.count is 5 then I expect 6 rows including the
header, instead I have 7 rows including the header.
What is in the extra row?
Also I suggest displaying @customer.deliveries.count in the page to
check it really is what you think.
Finally, unless this is rails 3, you should be using
h(product.description) for example, in case there is some html in the
description. Consider what would happen if the description included
</td></tr><tr> for example.
@customer.deliveries.count give 5 while the table has 6 lines.
Why?
Do you mean the table has a total of six rows? If yes then there is
the header row before the 5 data rows.
No no, including the header I have a total of 7 rows.
If @customer.deliveries.count is 5 then I expect 6 rows including the
header, instead I have 7 rows including the header.
What is in the extra row?
here is: <%= @customer.deliveries.count %> this command gives 6
well the header does not count, just the row of the database, maybe
the last dont its not a row, maybe is the append contentd of the last
row,
check out well your html format
maybe is the way you show the data why not prove like these
<% delivery.products.each do |product| %>
<%="Nothing, just to see if 5 row is display it" %>,
<% end %>
maybe is the way you show the data why not prove like these
<% delivery.products.each do |product| %>
<%="Nothing, just to see if 5 row is display it" %>,
<% end %>
If you do not already know how to use ruby-debug to break into your
code then have a look at the Rails Guide on debugging, then at this
point insert
<% debugger %>
and when you run it will break here and you can inspect the variables
and see what is going on.
One possiblity, have you changed @customer or its deliveries since it
was read from the database in such a way that the number of records in
the database (deliveries.count) does not match the current number of
deliveries in the object in memory?
the result of
SELECT "deliveries".* FROM "deliveries" WHERE ("deliveries".customer_id = 65145
and check out these
<%= @customer.deliveries.count %>
<% @customer.deliveries.each do |delivery| %>
<tr valign="top" class="<%= cycle('odd', 'even') %>">
<td> #just to compare what is in the database and what id is bringing to you
<%= delivery.id %>
</td>
</tr>
<% end %>
</tbody>
</table>
What are the results of breaking in with the debugger and inspecting the data
You have not answered whether you have done something in memory to
deliveries since @customer was picked up from the database (presumably
in the controller). Have you added another delivery in the controller
or view?