This project is archived and is in readonly mode.

#2053 ✓wontfix
ransom-briggs (at uiowa)

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

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>

People watching this ticket

Attachments

Pages