I am precisely documenting associations these days.

I think the problem is not related to #build itself, that method adds
the model to the target of the proxy just fine:

   [EMAIL PROTECTED]:~/tmp/test_associations$ cat test_build.rb
   post = Post.create
   post.comments.build
   puts post.comments.target.empty?
   [EMAIL PROTECTED]:~/tmp/test_associations$ script/runner test_build.rb
   false

Looks like the issue has to do with rendering collections somehow, if
you pass the target to the helper instead it works:

   <%= render :partial => "comment", :collection => @post.comments.target %>

Note that target is a getter for @target, load_target is not involved.

Looking further down, render_partial_collection has this line

   return " " if collection.empty?

empty? is equivalent to size.zero? for association collections and
#size does some stuff, so I guess we are getting close. The branch we
enter does take into account new records and performs a count_records
in case there was something in the database, the result is correct. In
fact the flow execution goes on, but *after* that line
collection.empty? is true (so the #map call afterwards does nothing
and no template gets rendered). My conjecture is that the call to
#size resets the proxy somehow.

I may complete the walkthrough later but that's what I've got by now.
Next target is count_records.

--~--~---------~--~----~------------~-------~--~----~
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