This project is archived and is in readonly mode.
has_many_assoc= and invalid associated instances
Reported by ransom-briggs (at uiowa) | February 23rd, 2009 @ 05:42 PM | in 2.x
See the attached test for example, but in english if you do the following...
a.posts = [p1, p2]
and p1 and p2 are invalid objects, the code in
vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:<<(*records)
at
result &&= insert_record(record) unless @owner.new_record?
runs for p1 but not p2, generating the side effect of p1 having author_id set, but p2 does not have author_id to be set.
this is the side result of the &&= which causes it not to run insert_record the second time.
My desired behavior would be that either both are set or neither are set (I would prefer both to be set for my purposes, but could see the opposite argument being made)
- Ransom
Comments and changes to this ticket
-
ransom-briggs (at uiowa) February 24th, 2009 @ 02:18 PM
result &&= insert_record(record) unless @owner.new_record?
in my eyes should be
unless @owner.new_record? result = insert_record(record) && result end
-
ransom-briggs (at uiowa) April 7th, 2009 @ 04:59 PM
- Assigned user set to Pratik
assigning to last committer
-
Pratik May 18th, 2009 @ 09:10 PM
- State changed from new to wontfix
Could you please submit a patch or a failing test ? http://guides.rubyonrails.org/contributing_to_rails.html is a start.
Thanks!
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>