Reassigning one-to-many association invokes dependent action improperly

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 2.4.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I've set up one-to-many association between users and ads (user has many ads, ad belongs to user) and have :autosave option set to true. When I reassign user's ads with 1 more ad it nullifies the user_id from the previous ad. Is this an intended behavior or a bug? Here is a simple test showing this case:

      ad1 = Ad.create!
      ad2 = Ad.create!
      user = User.create!(ads: [ad1])
      assert_equal [ad1], user.ads(true)
      user.ads = [ad1, ad2]
      user.save!
      assert_equal [ad1, ad2], user.ads(true) # fails, has only ad2
      

            Assignee:
            Unassigned
            Reporter:
            semaperepelitsa
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: