Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

has_many_assoc= and invalid associated instances

#2053

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

Reported by ransom-briggs (at uiowa) · February 23rd, 2009 @ 05:42 PM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. ransom-briggs (at uiowa)
    ransom-briggs (at uiowa)

    result &&= insert_record(record) unless @owner.new_record?

    in my eyes should be

              unless @owner.new_record?
                result = insert_record(record) && result
              end
    
    

    February 24th, 2009 @ 02:18 PM

  2. ransom-briggs (at uiowa)
    ransom-briggs (at uiowa)
    • Assigned user set to Pratik

    assigning to last committer

    April 7th, 2009 @ 04:59 PM

  3. Pratik
    Pratik
    • 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!

    May 18th, 2009 @ 09:10 PM