(I've posted the original issue in rails' github repository (6797) and 
follow up before, but I was recommended to discuss this problem here.)

Say I have a record post which has_many comments.
Calling post.dup would return a post whose id is not set. In which case I 
can save and create a new duplicated record of post.
Calling post.comments.dup would return an array of original comments, not a 
duplicate of the comment. This as explained to me was that rails doesn't 
override the array (that handles record collections in the association) in 
ruby.

However, post.comments << new_comment doesn't just push the new comment to 
the array, it actually inserts new_comment into database.

This seems to be inconsistent in how collection array is treated in both 
scenarios.

I'm interested in why the design is quite inconsistent in how associated 
collection is treated. Thanks in advance!

Yuklai

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/0cVh3Xb9_B0J.
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