[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Ryan Bigg
It would be loading the associated objects without checking to see if they are a #new_record?... seems like a bug to me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Johannes Fahrenkrug
Should I open a ticket for this? On Aug 19, 10:00 am, Ryan Bigg <[EMAIL PROTECTED]> wrote: > It would be loading the associated objects without checking to see if   > they are a #new_record?... seems like a bug to me. --~--~-~--~~~---~--~~ You received this message

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Xavier Noria
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.comm

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Xavier Noria
On Tue, Aug 19, 2008 at 5:10 PM, Xavier Noria <[EMAIL PROTECTED]> wrote: > 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. Bingo, I could

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Xavier Noria
Correct, a simple way to depict the underlying problem is: [EMAIL PROTECTED]:~/tmp/test_associations$ cat test_build.rb post = Post.create post.comments.build puts post.comments.size puts post.comments.size [EMAIL PROTECTED]:~/tmp/test_associations$ script/runner test_build.rb

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Frederick Cheung
On 19 Aug 2008, at 16:10, Xavier Noria wrote: > > 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 >

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Frederick Cheung
On 19 Aug 2008, at 16:39, Xavier Noria wrote: > > Correct, a simple way to depict the underlying problem is: > > [EMAIL PROTECTED]:~/tmp/test_associations$ cat test_build.rb > post = Post.create > post.comments.build > puts post.comments.size > puts post.comments.size > [EMAIL PROTEC

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Xavier Noria
On Tue, Aug 19, 2008 at 5:39 PM, Xavier Noria <[EMAIL PROTECTED]> wrote: > Correct, a simple way to depict the underlying problem is: > > [EMAIL PROTECTED]:~/tmp/test_associations$ cat test_build.rb > post = Post.create > post.comments.build > puts post.comments.size > puts post.comment

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Xavier Noria
On Tue, Aug 19, 2008 at 5:58 PM, Frederick Cheung <[EMAIL PROTECTED]> wrote: > Can you fix the other problem while you're in there? > currently if you do > > post = Post.create > post.comments.build > post.comments.build > puts post.comments.size > > the output is 1 Sure! I couldn't reproduce t

[Rails-core] Re: [Rails 2.1] association.build has to be "committed" by calling association.length or association.each

2008-08-19 Thread Frederick Cheung
On 20 Aug 2008, at 00:39, Xavier Noria wrote: > > On Tue, Aug 19, 2008 at 5:58 PM, Frederick Cheung > <[EMAIL PROTECTED]> wrote: > >> Can you fix the other problem while you're in there? >> currently if you do >> >> post = Post.create >> post.comments.build >> post.comments.build >> puts post.co