Hi,

I very careful about calling something a bug, so there's of course the
possibility that I'm simply doing something wrong, but I've
encountered some strange behavior:

I have a model with a has_many association, let's call them customer
and orders.
When I call customer.orders.build on an existing customer that doesn't
have any orders yet, and then want to let a partial iterate over the
orders to render each one, nothing happens.
When, however, I call customer.orders.length or customer.orders.each
{} right after build, it works.

So if I have a customer that doesn't have any orders yet and I do
this:

controller:
@customer.orders.build

view:
<%= render(:partial => 'order', :collection => @customer.orders) %>

... no order will be rendered.

When I do this, the order will be rendered:

controller:
@customer.orders.build
@customer.orders.length

view:
<%= render(:partial => 'order', :collection => @customer.orders) %>


I am using Rails 2.1. Is this a known issue? Am I doing something
wrong/misunderstanding something?

Could it possibly be related to this ticket in your old trac:
http://dev.rubyonrails.org/ticket/10203 ?

- Johannes

--
http://blog.springenwerk.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to