Re: [Rails] why I have one more line?
On 15 February 2011 12:23, Colin Law <clanlaw@googlemail.com> wrote:
> On 15 February 2011 12:12, Mauro <mrsanna1@gmail.com> wrote:
>> On 15 February 2011 12:04, Lorenzo Brito Morales
>> <lorenzo.brito@gmail.com> wrote:
>>> 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>
>>
>> @customer.deliveries.count = 4
>>
>> <% @customer.deliveries.each do |delivery| %>
>> <tr valign="top" class="<%= cycle('odd', 'even') %>">
>> <td>
>> <%= a+=1 %>
>> <%= delivery.id %>
>>
>> 1 3
>> 2 4
>> 3 5
>> 4 6
>> 5
>>
>> there is always one more row :-(
>
> What does deliveries.size give?
mmmm delvieries.count gives 4 while deliveries.size gives 5.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home